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

Side by Side Diff: chrome/browser/extensions/content_script_apitest.cc

Issue 2820333003: Revert of Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Created 3 years, 8 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/extensions/api/permissions/permissions_api.h" 14 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
15 #include "chrome/browser/extensions/extension_apitest.h" 15 #include "chrome/browser/extensions/extension_apitest.h"
16 #include "chrome/browser/extensions/extension_management_test_util.h"
17 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_with_management_policy_apitest.h"
19 #include "chrome/browser/extensions/test_extension_dir.h" 17 #include "chrome/browser/extensions/test_extension_dir.h"
20 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
23 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
24 #include "components/app_modal/javascript_dialog_extensions_client.h" 22 #include "components/app_modal/javascript_dialog_extensions_client.h"
25 #include "components/app_modal/javascript_dialog_manager.h" 23 #include "components/app_modal/javascript_dialog_manager.h"
26 #include "content/public/browser/javascript_dialog_manager.h" 24 #include "content/public/browser/javascript_dialog_manager.h"
27 #include "content/public/browser/render_frame_host.h" 25 #include "content/public/browser/render_frame_host.h"
28 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 #endif 496 #endif
499 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, 497 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest,
500 MAYBE_ContentScriptPermissionsApi) { 498 MAYBE_ContentScriptPermissionsApi) {
501 extensions::PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 499 extensions::PermissionsRequestFunction::SetIgnoreUserGestureForTests(true);
502 extensions::PermissionsRequestFunction::SetAutoConfirmForTests(true); 500 extensions::PermissionsRequestFunction::SetAutoConfirmForTests(true);
503 host_resolver()->AddRule("*.com", "127.0.0.1"); 501 host_resolver()->AddRule("*.com", "127.0.0.1");
504 ASSERT_TRUE(StartEmbeddedTestServer()); 502 ASSERT_TRUE(StartEmbeddedTestServer());
505 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; 503 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_;
506 } 504 }
507 505
508 IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy,
509 ContentScriptPolicy) {
510 // Set enterprise policy to block injection to policy specified host.
511 {
512 ExtensionManagementPolicyUpdater pref(&policy_provider_);
513 pref.AddRuntimeBlockedHost("*", "*://example.com/*");
514 }
515 host_resolver()->AddRule("*.com", "127.0.0.1");
516 ASSERT_TRUE(StartEmbeddedTestServer());
517 ASSERT_TRUE(RunExtensionTest("content_scripts/policy")) << message_;
518 }
519
520 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, ContentScriptBypassPageCSP) { 506 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, ContentScriptBypassPageCSP) {
521 ASSERT_TRUE(StartEmbeddedTestServer()); 507 ASSERT_TRUE(StartEmbeddedTestServer());
522 ASSERT_TRUE(RunExtensionTest("content_scripts/bypass_page_csp")) << message_; 508 ASSERT_TRUE(RunExtensionTest("content_scripts/bypass_page_csp")) << message_;
523 } 509 }
524 510
525 // Test that when injecting a blocking content script, other scripts don't run 511 // Test that when injecting a blocking content script, other scripts don't run
526 // until the blocking script finishes. 512 // until the blocking script finishes.
527 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, ContentScriptBlockingScript) { 513 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, ContentScriptBlockingScript) {
528 ASSERT_TRUE(StartEmbeddedTestServer()); 514 ASSERT_TRUE(StartEmbeddedTestServer());
529 515
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 EXPECT_FALSE(content_script_listener.was_satisfied()); 694 EXPECT_FALSE(content_script_listener.was_satisfied());
709 } 695 }
710 696
711 INSTANTIATE_TEST_CASE_P( 697 INSTANTIATE_TEST_CASE_P(
712 ContentScriptApiTests, 698 ContentScriptApiTests,
713 ContentScriptApiTest, 699 ContentScriptApiTest,
714 testing::Values(TestConfig::kDefault, 700 testing::Values(TestConfig::kDefault,
715 TestConfig::kYieldBetweenContentScriptRunsEnabled)); 701 TestConfig::kYieldBetweenContentScriptRunsEnabled));
716 702
717 } // namespace extensions 703 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/permissions/permissions_apitest.cc ('k') | chrome/browser/extensions/extension_management.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698