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

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

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: nits 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"
16 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_with_management_policy_apitest.h"
17 #include "chrome/browser/extensions/test_extension_dir.h" 19 #include "chrome/browser/extensions/test_extension_dir.h"
18 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
21 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
22 #include "components/app_modal/javascript_dialog_extensions_client.h" 24 #include "components/app_modal/javascript_dialog_extensions_client.h"
23 #include "components/app_modal/javascript_dialog_manager.h" 25 #include "components/app_modal/javascript_dialog_manager.h"
24 #include "content/public/browser/javascript_dialog_manager.h" 26 #include "content/public/browser/javascript_dialog_manager.h"
25 #include "content/public/browser/render_frame_host.h" 27 #include "content/public/browser/render_frame_host.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 #endif 498 #endif
497 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, 499 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest,
498 MAYBE_ContentScriptPermissionsApi) { 500 MAYBE_ContentScriptPermissionsApi) {
499 extensions::PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); 501 extensions::PermissionsRequestFunction::SetIgnoreUserGestureForTests(true);
500 extensions::PermissionsRequestFunction::SetAutoConfirmForTests(true); 502 extensions::PermissionsRequestFunction::SetAutoConfirmForTests(true);
501 host_resolver()->AddRule("*.com", "127.0.0.1"); 503 host_resolver()->AddRule("*.com", "127.0.0.1");
502 ASSERT_TRUE(StartEmbeddedTestServer()); 504 ASSERT_TRUE(StartEmbeddedTestServer());
503 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; 505 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_;
504 } 506 }
505 507
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
506 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, ContentScriptBypassPageCSP) { 520 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, ContentScriptBypassPageCSP) {
507 ASSERT_TRUE(StartEmbeddedTestServer()); 521 ASSERT_TRUE(StartEmbeddedTestServer());
508 ASSERT_TRUE(RunExtensionTest("content_scripts/bypass_page_csp")) << message_; 522 ASSERT_TRUE(RunExtensionTest("content_scripts/bypass_page_csp")) << message_;
509 } 523 }
510 524
511 // Test that when injecting a blocking content script, other scripts don't run 525 // Test that when injecting a blocking content script, other scripts don't run
512 // until the blocking script finishes. 526 // until the blocking script finishes.
513 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, ContentScriptBlockingScript) { 527 IN_PROC_BROWSER_TEST_P(ContentScriptApiTest, ContentScriptBlockingScript) {
514 ASSERT_TRUE(StartEmbeddedTestServer()); 528 ASSERT_TRUE(StartEmbeddedTestServer());
515 529
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 EXPECT_FALSE(content_script_listener.was_satisfied()); 708 EXPECT_FALSE(content_script_listener.was_satisfied());
695 } 709 }
696 710
697 INSTANTIATE_TEST_CASE_P( 711 INSTANTIATE_TEST_CASE_P(
698 ContentScriptApiTests, 712 ContentScriptApiTests,
699 ContentScriptApiTest, 713 ContentScriptApiTest,
700 testing::Values(TestConfig::kDefault, 714 testing::Values(TestConfig::kDefault,
701 TestConfig::kYieldBetweenContentScriptRunsEnabled)); 715 TestConfig::kYieldBetweenContentScriptRunsEnabled));
702 716
703 } // namespace extensions 717 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698