blob: ccb134b0969ba356afa8899a9465e53110c022de [file] [log] [blame]
[email protected]fad73672012-06-15 23:26:061// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]c80b8ee2011-12-03 04:26:522// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Contains holistic tests of the bindings infrastructure
6
Gabriel Charette078e3662017-08-28 22:59:047#include "base/run_loop.h"
Devlin Cronina3fe3d602017-11-22 04:47:438#include "base/test/scoped_feature_list.h"
[email protected]7eef3942013-08-14 02:53:499#include "chrome/browser/extensions/api/permissions/permissions_api.h"
[email protected]c80b8ee2011-12-03 04:26:5210#include "chrome/browser/extensions/extension_apitest.h"
jochen7923c2a2015-07-14 10:04:4511#include "chrome/browser/net/url_request_mock_util.h"
[email protected]fad73672012-06-15 23:26:0612#include "chrome/browser/ui/browser.h"
rdevlin.cronin83a4b3a2015-10-28 21:43:5813#include "chrome/browser/ui/tabs/tab_strip_model.h"
asargent79b64c32016-08-04 17:17:1414#include "chrome/common/chrome_switches.h"
rdevlin.cronin83a4b3a2015-10-28 21:43:5815#include "chrome/test/base/ui_test_utils.h"
jochen7923c2a2015-07-14 10:04:4516#include "content/public/browser/browser_thread.h"
Devlin Croninb15c4f4e2017-12-15 21:20:1117#include "content/public/browser/render_frame_host.h"
[email protected]7d478cb2012-07-24 17:19:4218#include "content/public/test/browser_test_utils.h"
[email protected]22401dc2014-03-21 01:38:5719#include "extensions/browser/extension_host.h"
[email protected]98b6d942013-11-10 00:34:0720#include "extensions/browser/process_manager.h"
Devlin Cronina3fe3d602017-11-22 04:47:4321#include "extensions/common/extension_features.h"
lfg910f2f92014-09-19 05:31:0922#include "extensions/test/extension_test_message_listener.h"
yoze8dc2f12014-09-09 23:16:3223#include "extensions/test/result_catcher.h"
rdevlin.cronine6e20022017-06-13 18:23:4024#include "net/dns/mock_host_resolver.h"
rdevlin.cronin83a4b3a2015-10-28 21:43:5825#include "net/test/embedded_test_server/embedded_test_server.h"
[email protected]fad73672012-06-15 23:26:0626
[email protected]adafe5b2013-08-09 10:35:0427namespace extensions {
28namespace {
29
Devlin Croninc3a1e5072017-08-17 17:02:4930enum BindingsType { NATIVE_BINDINGS, JAVASCRIPT_BINDINGS };
31
32class ExtensionBindingsApiTest
33 : public ExtensionApiTest,
34 public ::testing::WithParamInterface<BindingsType> {
jochen7923c2a2015-07-14 10:04:4535 public:
Devlin Cronina3fe3d602017-11-22 04:47:4336 ExtensionBindingsApiTest() {}
37 ~ExtensionBindingsApiTest() override {}
38
39 void SetUp() override {
40 if (GetParam() == NATIVE_BINDINGS) {
41 scoped_feature_list_.InitAndEnableFeature(features::kNativeCrxBindings);
42 } else {
43 DCHECK_EQ(JAVASCRIPT_BINDINGS, GetParam());
44 scoped_feature_list_.InitAndDisableFeature(features::kNativeCrxBindings);
45 }
46 ExtensionApiTest::SetUp();
Devlin Croninc3a1e5072017-08-17 17:02:4947 }
48
jochen7923c2a2015-07-14 10:04:4549 void SetUpOnMainThread() override {
rdevlin.cronin17160cc62016-11-23 05:33:0850 ExtensionApiTest::SetUpOnMainThread();
rdevlin.cronine6e20022017-06-13 18:23:4051 host_resolver()->AddRule("*", "127.0.0.1");
52 ASSERT_TRUE(StartEmbeddedTestServer());
jochen7923c2a2015-07-14 10:04:4553 }
Devlin Cronina3fe3d602017-11-22 04:47:4354
55 private:
56 base::test::ScopedFeatureList scoped_feature_list_;
57
58 DISALLOW_COPY_AND_ASSIGN(ExtensionBindingsApiTest);
jochen7923c2a2015-07-14 10:04:4559};
[email protected]adafe5b2013-08-09 10:35:0460
Devlin Croninc3a1e5072017-08-17 17:02:4961IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest,
[email protected]7eef3942013-08-14 02:53:4962 UnavailableBindingsNeverRegistered) {
63 // Test will request the 'storage' permission.
64 PermissionsRequestFunction::SetIgnoreUserGestureForTests(true);
65 ASSERT_TRUE(RunExtensionTest(
66 "bindings/unavailable_bindings_never_registered")) << message_;
67}
68
Devlin Croninc3a1e5072017-08-17 17:02:4969IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest,
[email protected]adafe5b2013-08-09 10:35:0470 ExceptionInHandlerShouldNotCrash) {
[email protected]c80b8ee2011-12-03 04:26:5271 ASSERT_TRUE(RunExtensionSubtest(
72 "bindings/exception_in_handler_should_not_crash",
73 "page.html")) << message_;
74}
[email protected]fad73672012-06-15 23:26:0675
76// Tests that an error raised during an async function still fires
[email protected]754ea8b72013-01-08 15:10:3177// the callback, but sets chrome.runtime.lastError.
Devlin Croninc3a1e5072017-08-17 17:02:4978IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, LastError) {
[email protected]fad73672012-06-15 23:26:0679 ASSERT_TRUE(LoadExtension(
Devlin Croninc3a1e5072017-08-17 17:02:4980 test_data_dir_.AppendASCII("bindings").AppendASCII("last_error")));
[email protected]fad73672012-06-15 23:26:0681
82 // Get the ExtensionHost that is hosting our background page.
[email protected]98b6d942013-11-10 00:34:0783 extensions::ProcessManager* manager =
reillyg0ea3fa902014-10-28 15:30:2384 extensions::ProcessManager::Get(browser()->profile());
[email protected]3a1dc572012-07-31 22:25:1385 extensions::ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1);
[email protected]fad73672012-06-15 23:26:0686
87 bool result = false;
[email protected]b6987e02013-01-04 18:30:4388 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
89 host->render_view_host(), "testLastError()", &result));
[email protected]fad73672012-06-15 23:26:0690 EXPECT_TRUE(result);
91}
[email protected]52eafbd2013-04-03 04:43:1992
[email protected]adafe5b2013-08-09 10:35:0493// Regression test that we don't delete our own bindings with about:blank
94// iframes.
Devlin Croninc3a1e5072017-08-17 17:02:4995IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, AboutBlankIframe) {
[email protected]adafe5b2013-08-09 10:35:0496 ResultCatcher catcher;
97 ExtensionTestMessageListener listener("load", true);
98
99 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("bindings")
100 .AppendASCII("about_blank_iframe")));
101
102 ASSERT_TRUE(listener.WaitUntilSatisfied());
103
104 const Extension* extension = LoadExtension(
105 test_data_dir_.AppendASCII("bindings")
106 .AppendASCII("internal_apis_not_on_chrome_object"));
107 ASSERT_TRUE(extension);
108 listener.Reply(extension->id());
109
110 ASSERT_TRUE(catcher.GetNextResult()) << message_;
111}
112
Devlin Croninc3a1e5072017-08-17 17:02:49113IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest,
[email protected]adafe5b2013-08-09 10:35:04114 InternalAPIsNotOnChromeObject) {
[email protected]52eafbd2013-04-03 04:43:19115 ASSERT_TRUE(RunExtensionSubtest(
116 "bindings/internal_apis_not_on_chrome_object",
117 "page.html")) << message_;
118}
[email protected]adafe5b2013-08-09 10:35:04119
[email protected]fc034482013-08-09 20:25:14120// Tests that we don't override events when bindings are re-injected.
121// Regression test for http://crbug.com/269149.
rpaquay96bf3b7d2014-11-26 00:19:08122// Regression test for http://crbug.com/436593.
Henrik Grunell6b7d9db2017-06-14 10:27:20123// Flaky on Mac. http://crbug.com/733064.
Giovanni Ortuño Urquidi7ce215452017-06-14 03:34:08124#if defined(OS_MACOSX)
125#define MAYBE_EventOverriding DISABLED_EventOverriding
126#else
127#define MAYBE_EventOverriding EventOverriding
128#endif
Devlin Croninc3a1e5072017-08-17 17:02:49129IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, MAYBE_EventOverriding) {
[email protected]fc034482013-08-09 20:25:14130 ASSERT_TRUE(RunExtensionTest("bindings/event_overriding")) << message_;
rdevlin.cronind734f682017-06-13 21:23:11131 // The extension test removes a window and, during window removal, sends the
132 // success message. Make sure we flush all pending tasks.
133 base::RunLoop().RunUntilIdle();
[email protected]fc034482013-08-09 20:25:14134}
135
kalman1bd5b182015-01-13 19:01:18136// Tests the effectiveness of the 'nocompile' feature file property.
137// Regression test for http://crbug.com/356133.
Devlin Croninc3a1e5072017-08-17 17:02:49138IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, Nocompile) {
kalman1bd5b182015-01-13 19:01:18139 ASSERT_TRUE(RunExtensionSubtest("bindings/nocompile", "page.html"))
140 << message_;
141}
142
Devlin Croninc3a1e5072017-08-17 17:02:49143IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, ApiEnums) {
rdevlin.cronin2ba3c88d2015-03-03 01:18:22144 ASSERT_TRUE(RunExtensionTest("bindings/api_enums")) << message_;
145};
146
jochen7923c2a2015-07-14 10:04:45147// Regression test for http://crbug.com/504011 - proper access checks on
148// getModuleSystem().
Devlin Croninc3a1e5072017-08-17 17:02:49149IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, ModuleSystem) {
jochen7923c2a2015-07-14 10:04:45150 ASSERT_TRUE(RunExtensionTest("bindings/module_system")) << message_;
151}
152
Devlin Croninc3a1e5072017-08-17 17:02:49153IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, NoExportOverriding) {
rdevlin.cronin83a4b3a2015-10-28 21:43:58154 // We need to create runtime bindings in the web page. An extension that's
155 // externally connectable will do that for us.
156 ASSERT_TRUE(LoadExtension(
157 test_data_dir_.AppendASCII("bindings")
158 .AppendASCII("externally_connectable_everywhere")));
159
160 ui_test_utils::NavigateToURL(
161 browser(),
162 embedded_test_server()->GetURL(
163 "/extensions/api_test/bindings/override_exports.html"));
164
165 // See chrome/test/data/extensions/api_test/bindings/override_exports.html.
166 std::string result;
167 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
168 browser()->tab_strip_model()->GetActiveWebContents(),
169 "window.domAutomationController.send("
170 "document.getElementById('status').textContent.trim());",
171 &result));
172 EXPECT_EQ("success", result);
173}
174
Devlin Croninc3a1e5072017-08-17 17:02:49175IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, NoGinDefineOverriding) {
rdevlin.cronin415b73b2015-11-13 01:14:47176 // We need to create runtime bindings in the web page. An extension that's
177 // externally connectable will do that for us.
178 ASSERT_TRUE(LoadExtension(
179 test_data_dir_.AppendASCII("bindings")
180 .AppendASCII("externally_connectable_everywhere")));
181
182 ui_test_utils::NavigateToURL(
183 browser(),
184 embedded_test_server()->GetURL(
185 "/extensions/api_test/bindings/override_gin_define.html"));
186 ASSERT_FALSE(
187 browser()->tab_strip_model()->GetActiveWebContents()->IsCrashed());
188
189 // See chrome/test/data/extensions/api_test/bindings/override_gin_define.html.
190 std::string result;
191 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
192 browser()->tab_strip_model()->GetActiveWebContents(),
193 "window.domAutomationController.send("
194 "document.getElementById('status').textContent.trim());",
195 &result));
196 EXPECT_EQ("success", result);
197}
198
Devlin Croninc3a1e5072017-08-17 17:02:49199IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, HandlerFunctionTypeChecking) {
rdevlin.cronina5ecbc82015-10-29 23:41:29200 ui_test_utils::NavigateToURL(
201 browser(),
202 embedded_test_server()->GetURL(
203 "/extensions/api_test/bindings/handler_function_type_checking.html"));
204 content::WebContents* web_contents =
205 browser()->tab_strip_model()->GetActiveWebContents();
206 EXPECT_FALSE(web_contents->IsCrashed());
207 // See handler_function_type_checking.html.
208 std::string result;
209 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
210 web_contents,
211 "window.domAutomationController.send("
212 "document.getElementById('status').textContent.trim());",
213 &result));
214 EXPECT_EQ("success", result);
215}
216
Devlin Croninc3a1e5072017-08-17 17:02:49217IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest,
rdevlin.cronin75b803b2016-03-02 00:13:47218 MoreNativeFunctionInterceptionTests) {
rdevlin.cronin75b803b2016-03-02 00:13:47219 // We need to create runtime bindings in the web page. An extension that's
220 // externally connectable will do that for us.
221 ASSERT_TRUE(
222 LoadExtension(test_data_dir_.AppendASCII("bindings")
223 .AppendASCII("externally_connectable_everywhere")));
224
225 ui_test_utils::NavigateToURL(
226 browser(),
227 embedded_test_server()->GetURL(
228 "/extensions/api_test/bindings/function_interceptions.html"));
229 content::WebContents* web_contents =
230 browser()->tab_strip_model()->GetActiveWebContents();
231 EXPECT_FALSE(web_contents->IsCrashed());
232 // See function_interceptions.html.
233 std::string result;
234 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
235 web_contents, "window.domAutomationController.send(window.testStatus);",
236 &result));
237 EXPECT_EQ("success", result);
238}
239
asargent79b64c32016-08-04 17:17:14240class FramesExtensionBindingsApiTest : public ExtensionBindingsApiTest {
241 public:
242 void SetUpCommandLine(base::CommandLine* command_line) override {
243 ExtensionBindingsApiTest::SetUpCommandLine(command_line);
Devlin Croninc3a1e5072017-08-17 17:02:49244 command_line->AppendSwitch(::switches::kDisablePopupBlocking);
asargent79b64c32016-08-04 17:17:14245 }
246};
247
248// This tests that web pages with iframes or child windows pointing at
249// chrome-extenison:// urls, both web_accessible and nonexistent pages, don't
250// get improper extensions bindings injected while they briefly still point at
251// about:blank and are still scriptable by their parent.
252//
253// The general idea is to load up 2 extensions, one which listens for external
254// messages ("receiver") and one which we'll try first faking messages from in
255// the web page's iframe, as well as actually send a message from later
256// ("sender").
Dave Tapuska61ed7fbb2017-09-05 21:42:08257IN_PROC_BROWSER_TEST_P(FramesExtensionBindingsApiTest, FramesBeforeNavigation) {
asargent79b64c32016-08-04 17:17:14258 // Load the sender and receiver extensions, and make sure they are ready.
259 ExtensionTestMessageListener sender_ready("sender_ready", true);
260 const Extension* sender = LoadExtension(
261 test_data_dir_.AppendASCII("bindings").AppendASCII("message_sender"));
262 ASSERT_NE(nullptr, sender);
263 ASSERT_TRUE(sender_ready.WaitUntilSatisfied());
264
265 ExtensionTestMessageListener receiver_ready("receiver_ready", false);
266 const Extension* receiver =
267 LoadExtension(test_data_dir_.AppendASCII("bindings")
268 .AppendASCII("external_message_listener"));
269 ASSERT_NE(nullptr, receiver);
270 ASSERT_TRUE(receiver_ready.WaitUntilSatisfied());
271
272 // Load the web page which tries to impersonate the sender extension via
273 // scripting iframes/child windows before they finish navigating to pages
274 // within the sender extension.
asargent79b64c32016-08-04 17:17:14275 ui_test_utils::NavigateToURL(
276 browser(),
277 embedded_test_server()->GetURL(
278 "/extensions/api_test/bindings/frames_before_navigation.html"));
279
280 bool page_success = false;
281 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
282 browser()->tab_strip_model()->GetWebContentsAt(0), "getResult()",
283 &page_success));
284 EXPECT_TRUE(page_success);
285
286 // Reply to |sender|, causing it to send a message over to |receiver|, and
287 // then ask |receiver| for the total message count. It should be 1 since
288 // |receiver| should not have received any impersonated messages.
289 sender_ready.Reply(receiver->id());
290 int message_count = 0;
291 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
292 ProcessManager::Get(profile())
293 ->GetBackgroundHostForExtension(receiver->id())
294 ->host_contents(),
295 "getMessageCountAfterReceivingRealSenderMessage()", &message_count));
296 EXPECT_EQ(1, message_count);
297}
298
Devlin Croninc3a1e5072017-08-17 17:02:49299IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, TestFreezingChrome) {
rdevlin.cronin741da002017-04-24 20:27:41300 ui_test_utils::NavigateToURL(
301 browser(), embedded_test_server()->GetURL(
302 "/extensions/api_test/bindings/freeze.html"));
303 content::WebContents* web_contents =
304 browser()->tab_strip_model()->GetActiveWebContents();
305 ASSERT_FALSE(web_contents->IsCrashed());
306}
307
rdevlin.cronine6e20022017-06-13 18:23:40308// Tests interaction with event filter parsing.
Devlin Croninc3a1e5072017-08-17 17:02:49309IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, TestEventFilterParsing) {
rdevlin.cronine6e20022017-06-13 18:23:40310 ExtensionTestMessageListener listener("ready", false);
311 ASSERT_TRUE(
312 LoadExtension(test_data_dir_.AppendASCII("bindings/event_filter")));
313 ASSERT_TRUE(listener.WaitUntilSatisfied());
314
315 ResultCatcher catcher;
316 ui_test_utils::NavigateToURL(
317 browser(), embedded_test_server()->GetURL("example.com", "/title1.html"));
318 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
319}
320
rdevlin.cronin350824d42017-06-16 14:47:35321// crbug.com/733337
Devlin Croninc3a1e5072017-08-17 17:02:49322IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, ValidationInterception) {
rdevlin.cronin350824d42017-06-16 14:47:35323 // We need to create runtime bindings in the web page. An extension that's
324 // externally connectable will do that for us.
325 ASSERT_TRUE(
326 LoadExtension(test_data_dir_.AppendASCII("bindings")
327 .AppendASCII("externally_connectable_everywhere")));
328
329 content::WebContents* web_contents =
330 browser()->tab_strip_model()->GetActiveWebContents();
331 ui_test_utils::NavigateToURL(
332 browser(),
333 embedded_test_server()->GetURL(
334 "/extensions/api_test/bindings/validation_interception.html"));
335 content::WaitForLoadStop(web_contents);
336 ASSERT_FALSE(web_contents->IsCrashed());
337 bool caught = false;
338 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
339 web_contents, "domAutomationController.send(caught)", &caught));
340 EXPECT_TRUE(caught);
341}
342
Devlin Cronin5cf20f02017-10-10 14:25:04343IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, UncaughtExceptionLogging) {
344 ASSERT_TRUE(RunExtensionTest("bindings/uncaught_exception_logging"))
345 << message_;
346}
347
Alex Moshchuke63b9e92017-10-14 00:27:22348// Verify that when a web frame embeds an extension subframe, and that subframe
349// is the only active portion of the extension, the subframe gets proper JS
350// bindings. See https://crbug.com/760341.
351IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest,
352 ExtensionSubframeGetsBindings) {
353 // Load an extension that does not have a background page or popup, so it
354 // won't be activated just yet.
355 const extensions::Extension* extension =
356 LoadExtension(test_data_dir_.AppendASCII("bindings")
357 .AppendASCII("extension_subframe_gets_bindings"));
358 ASSERT_TRUE(extension);
359
360 // Navigate current tab to a web URL with a subframe.
361 content::WebContents* web_contents =
362 browser()->tab_strip_model()->GetActiveWebContents();
363 ui_test_utils::NavigateToURL(browser(),
364 embedded_test_server()->GetURL("/iframe.html"));
365
366 // Navigate the subframe to the extension URL, which should activate the
367 // extension.
368 GURL extension_url(extension->GetResourceURL("page.html"));
369 ResultCatcher catcher;
370 content::NavigateIframeToURL(web_contents, "test", extension_url);
371 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
372}
373
Devlin Croninb15c4f4e2017-12-15 21:20:11374IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest,
375 ExtensionListenersRemoveContext) {
376 const Extension* extension = LoadExtension(
377 test_data_dir_.AppendASCII("bindings/listeners_destroy_context"));
378 ASSERT_TRUE(extension);
379
380 ExtensionTestMessageListener listener("ready", true);
381
382 // Navigate to a web page with an iframe (the iframe is title1.html).
383 GURL main_frame_url = embedded_test_server()->GetURL("a.com", "/iframe.html");
384 ui_test_utils::NavigateToURL(browser(), main_frame_url);
385
386 content::WebContents* tab =
387 browser()->tab_strip_model()->GetActiveWebContents();
388
389 content::RenderFrameHost* main_frame = tab->GetMainFrame();
390 content::RenderFrameHost* subframe = ChildFrameAt(main_frame, 0);
391 content::RenderFrameDeletedObserver subframe_deleted(subframe);
392
393 // Wait for the extension's content script to be ready.
394 ASSERT_TRUE(listener.WaitUntilSatisfied());
395
396 // It's actually critical to the test that these frames are in the same
397 // process, because otherwise a crash in the iframe wouldn't be detectable
398 // (since we rely on JS execution in the main frame to tell if the renderer
399 // crashed - see comment below).
400 content::RenderProcessHost* main_frame_process = main_frame->GetProcess();
401 EXPECT_EQ(main_frame_process, subframe->GetProcess());
402
403 ExtensionTestMessageListener failure_listener("failed", false);
404
405 // Tell the extension to register listeners that will remove the iframe, and
406 // trigger them.
407 listener.Reply("go!");
408
409 // The frame will be deleted.
410 subframe_deleted.WaitUntilDeleted();
411
412 // Unfortunately, we don't have a good way of checking if something crashed
413 // after the frame was removed. WebContents::IsCrashed() seems like it should
414 // work, but is insufficient. Instead, use JS execution as the source of
415 // true.
416 EXPECT_FALSE(tab->IsCrashed());
417 EXPECT_EQ(main_frame_url, main_frame->GetLastCommittedURL());
418 EXPECT_EQ(main_frame_process, main_frame->GetProcess());
419 bool renderer_valid = false;
420 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
421 main_frame, "domAutomationController.send(true);", &renderer_valid));
422 EXPECT_TRUE(renderer_valid);
423 EXPECT_FALSE(failure_listener.was_satisfied());
424}
425
Devlin Croninb48b6f92018-01-12 23:17:59426IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest, UseAPIsAfterContextRemoval) {
427 EXPECT_TRUE(RunExtensionTest("bindings/invalidate_context")) << message_;
428}
429
Devlin Croninc3a1e5072017-08-17 17:02:49430// Run core bindings API tests with both native and JS-based bindings. This
431// ensures we have some minimum level of coverage while in the experimental
432// phase, when native bindings may be enabled on trunk but not at 100% stable.
433INSTANTIATE_TEST_CASE_P(Native,
434 ExtensionBindingsApiTest,
435 ::testing::Values(NATIVE_BINDINGS));
436INSTANTIATE_TEST_CASE_P(JavaScript,
437 ExtensionBindingsApiTest,
438 ::testing::Values(JAVASCRIPT_BINDINGS));
439
440INSTANTIATE_TEST_CASE_P(Native,
441 FramesExtensionBindingsApiTest,
442 ::testing::Values(NATIVE_BINDINGS));
443INSTANTIATE_TEST_CASE_P(JavaScript,
444 FramesExtensionBindingsApiTest,
445 ::testing::Values(JAVASCRIPT_BINDINGS));
446
[email protected]adafe5b2013-08-09 10:35:04447} // namespace
448} // namespace extensions