Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_apitest.cc

Issue 2017113002: [Extensions] DCHECK that ExtensionFunctions respond (and only once) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 bool load_extension_with_incognito_permission, 271 bool load_extension_with_incognito_permission,
272 bool wait_for_extension_loaded_in_incognito, 272 bool wait_for_extension_loaded_in_incognito,
273 const char* expected_content_regular_window, 273 const char* expected_content_regular_window,
274 const char* exptected_content_incognito_window) { 274 const char* exptected_content_incognito_window) {
275 ResultCatcher catcher; 275 ResultCatcher catcher;
276 catcher.RestrictToBrowserContext(browser()->profile()); 276 catcher.RestrictToBrowserContext(browser()->profile());
277 ResultCatcher catcher_incognito; 277 ResultCatcher catcher_incognito;
278 catcher_incognito.RestrictToBrowserContext( 278 catcher_incognito.RestrictToBrowserContext(
279 browser()->profile()->GetOffTheRecordProfile()); 279 browser()->profile()->GetOffTheRecordProfile());
280 280
281 ExtensionTestMessageListener listener("done", true); 281 ExtensionTestMessageListener listener("done", false);
282 ExtensionTestMessageListener listener_incognito("done_incognito", true); 282 ExtensionTestMessageListener listener_incognito("done_incognito", false);
283 283
284 int load_extension_flags = kFlagNone; 284 int load_extension_flags = kFlagNone;
285 if (load_extension_with_incognito_permission) 285 if (load_extension_with_incognito_permission)
286 load_extension_flags |= kFlagEnableIncognito; 286 load_extension_flags |= kFlagEnableIncognito;
287 ASSERT_TRUE(LoadExtensionWithFlags( 287 ASSERT_TRUE(LoadExtensionWithFlags(
288 test_data_dir_.AppendASCII("webrequest_permissions") 288 test_data_dir_.AppendASCII("webrequest_permissions")
289 .AppendASCII(extension_directory), 289 .AppendASCII(extension_directory),
290 load_extension_flags)); 290 load_extension_flags));
291 291
292 // Test that navigation in regular window is properly redirected. 292 // Test that navigation in regular window is properly redirected.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 ASSERT_TRUE(StartEmbeddedTestServer()); 383 ASSERT_TRUE(StartEmbeddedTestServer());
384 ASSERT_TRUE(RunExtensionTest("webrequest_sendmessage")) << message_; 384 ASSERT_TRUE(RunExtensionTest("webrequest_sendmessage")) << message_;
385 } 385 }
386 386
387 // Check that reloading an extension that runs in incognito split mode and 387 // Check that reloading an extension that runs in incognito split mode and
388 // has two active background pages with registered events does not crash the 388 // has two active background pages with registered events does not crash the
389 // browser. Regression test for http://crbug.com/224094 389 // browser. Regression test for http://crbug.com/224094
390 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, IncognitoSplitModeReload) { 390 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, IncognitoSplitModeReload) {
391 ASSERT_TRUE(StartEmbeddedTestServer()); 391 ASSERT_TRUE(StartEmbeddedTestServer());
392 // Wait for rules to be set up. 392 // Wait for rules to be set up.
393 ExtensionTestMessageListener listener("done", true); 393 ExtensionTestMessageListener listener("done", false);
394 ExtensionTestMessageListener listener_incognito("done_incognito", true); 394 ExtensionTestMessageListener listener_incognito("done_incognito", false);
395 395
396 const Extension* extension = LoadExtensionWithFlags( 396 const Extension* extension = LoadExtensionWithFlags(
397 test_data_dir_.AppendASCII("webrequest_reload"), kFlagEnableIncognito); 397 test_data_dir_.AppendASCII("webrequest_reload"), kFlagEnableIncognito);
398 ASSERT_TRUE(extension); 398 ASSERT_TRUE(extension);
399 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); 399 OpenURLOffTheRecord(browser()->profile(), GURL("about:blank"));
400 400
401 EXPECT_TRUE(listener.WaitUntilSatisfied()); 401 EXPECT_TRUE(listener.WaitUntilSatisfied());
402 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied()); 402 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied());
403 403
404 // Reload extension and wait for rules to be set up again. This should not 404 // Reload extension and wait for rules to be set up again. This should not
405 // crash the browser. 405 // crash the browser.
406 ExtensionTestMessageListener listener2("done", true); 406 ExtensionTestMessageListener listener2("done", false);
407 ExtensionTestMessageListener listener_incognito2("done_incognito", true); 407 ExtensionTestMessageListener listener_incognito2("done_incognito", false);
408 408
409 ReloadExtension(extension->id()); 409 ReloadExtension(extension->id());
410 410
411 EXPECT_TRUE(listener2.WaitUntilSatisfied()); 411 EXPECT_TRUE(listener2.WaitUntilSatisfied());
412 EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied()); 412 EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied());
413 } 413 }
414 414
415 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, ExtensionRequests) { 415 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, ExtensionRequests) {
416 ASSERT_TRUE(StartEmbeddedTestServer()); 416 ASSERT_TRUE(StartEmbeddedTestServer());
417 ExtensionTestMessageListener listener_main1("web_request_status1", true); 417 ExtensionTestMessageListener listener_main1("web_request_status1", true);
418 ExtensionTestMessageListener listener_main2("web_request_status2", true); 418 ExtensionTestMessageListener listener_main2("web_request_status2", true);
419 419
420 ExtensionTestMessageListener listener_app("app_done", false); 420 ExtensionTestMessageListener listener_app("app_done", false);
421 ExtensionTestMessageListener listener_extension("extension_done", true); 421 ExtensionTestMessageListener listener_extension("extension_done", false);
422 422
423 // Set up webRequest listener 423 // Set up webRequest listener
424 ASSERT_TRUE(LoadExtension( 424 ASSERT_TRUE(LoadExtension(
425 test_data_dir_.AppendASCII("webrequest_extensions/main"))); 425 test_data_dir_.AppendASCII("webrequest_extensions/main")));
426 EXPECT_TRUE(listener_main1.WaitUntilSatisfied()); 426 EXPECT_TRUE(listener_main1.WaitUntilSatisfied());
427 EXPECT_TRUE(listener_main2.WaitUntilSatisfied()); 427 EXPECT_TRUE(listener_main2.WaitUntilSatisfied());
428 428
429 // Perform some network activity in an app and another extension. 429 // Perform some network activity in an app and another extension.
430 ASSERT_TRUE(LoadExtension( 430 ASSERT_TRUE(LoadExtension(
431 test_data_dir_.AppendASCII("webrequest_extensions/app"))); 431 test_data_dir_.AppendASCII("webrequest_extensions/app")));
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 ASSERT_TRUE(granter); 578 ASSERT_TRUE(granter);
579 granter->RevokeForTesting(); 579 granter->RevokeForTesting();
580 base::RunLoop().RunUntilIdle(); 580 base::RunLoop().RunUntilIdle();
581 PerformXhrInPage(web_contents, kHost, port, kXhrPath); 581 PerformXhrInPage(web_contents, kHost, port, kXhrPath);
582 EXPECT_EQ(xhr_count, 582 EXPECT_EQ(xhr_count,
583 GetWebRequestCountFromBackgroundPage(extension, profile())); 583 GetWebRequestCountFromBackgroundPage(extension, profile()));
584 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); 584 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension));
585 } 585 }
586 586
587 } // namespace extensions 587 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698