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

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

Issue 10863002: Added check to prevent extensions from injecting scrips into other extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/extensions/api/permissions/permissions_api.h" 6 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_tabstrip.h" 10 #include "chrome/browser/ui/browser_tabstrip.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ui_test_utils::GetCurrentTabTitle(browser(), &title); 76 ui_test_utils::GetCurrentTabTitle(browser(), &title);
77 EXPECT_EQ(std::string("PASS"), UTF16ToUTF8(title)); 77 EXPECT_EQ(std::string("PASS"), UTF16ToUTF8(title));
78 } 78 }
79 79
80 // crbug.com/39249 -- content scripts js should not run on view source. 80 // crbug.com/39249 -- content scripts js should not run on view source.
81 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptViewSource) { 81 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptViewSource) {
82 ASSERT_TRUE(StartTestServer()); 82 ASSERT_TRUE(StartTestServer());
83 ASSERT_TRUE(RunExtensionTest("content_scripts/view_source")) << message_; 83 ASSERT_TRUE(RunExtensionTest("content_scripts/view_source")) << message_;
84 } 84 }
85 85
86 // crbug.com/126257 -- content scripts should not get injected into other
87 // extensions.
88 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptOtherExtensions) {
89 host_resolver()->AddRule("a.com", "127.0.0.1");
90 ASSERT_TRUE(StartTestServer());
91 // First, load extension that sets up content script.
92 ASSERT_TRUE(RunExtensionTest("content_scripts/other_extensions/injector"))
93 << message_;
94 // Then load targeted extension to make sure its content isn't changed.
95 ASSERT_TRUE(RunExtensionTest("content_scripts/other_extensions/victim"))
96 << message_;
97 }
98
86 // crbug.com/120762 99 // crbug.com/120762
87 IN_PROC_BROWSER_TEST_F( 100 IN_PROC_BROWSER_TEST_F(
88 ExtensionApiTest, 101 ExtensionApiTest,
89 DISABLED_ContentScriptStylesInjectedIntoExistingRenderers) { 102 DISABLED_ContentScriptStylesInjectedIntoExistingRenderers) {
90 ASSERT_TRUE(StartTestServer()); 103 ASSERT_TRUE(StartTestServer());
91 104
92 content::WindowedNotificationObserver signal( 105 content::WindowedNotificationObserver signal(
93 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, 106 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
94 content::Source<Profile>(browser()->profile())); 107 content::Source<Profile>(browser()->profile()));
95 108
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 EXPECT_TRUE(catcher.GetNextResult()); 155 EXPECT_TRUE(catcher.GetNextResult());
143 } 156 }
144 157
145 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptPermissionsApi) { 158 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptPermissionsApi) {
146 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true); 159 RequestPermissionsFunction::SetIgnoreUserGestureForTests(true);
147 RequestPermissionsFunction::SetAutoConfirmForTests(true); 160 RequestPermissionsFunction::SetAutoConfirmForTests(true);
148 host_resolver()->AddRule("*.com", "127.0.0.1"); 161 host_resolver()->AddRule("*.com", "127.0.0.1");
149 ASSERT_TRUE(StartTestServer()); 162 ASSERT_TRUE(StartTestServer());
150 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; 163 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_;
151 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698