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

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

Issue 1335083004: [Extensions] Don't allow extensions to inject scripts into extension pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/content_scripts/background_page_iframe/background.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/api/permissions/permissions_api.h" 9 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 EXPECT_FALSE(listener.was_satisfied()); 608 EXPECT_FALSE(listener.was_satisfied());
609 listener.Reset(); 609 listener.Reset();
610 610
611 ui_test_utils::NavigateToURLWithDisposition( 611 ui_test_utils::NavigateToURLWithDisposition(
612 browser(), embedded_test_server()->GetURL("/empty.html"), 612 browser(), embedded_test_server()->GetURL("/empty.html"),
613 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 613 CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
614 base::RunLoop().RunUntilIdle(); 614 base::RunLoop().RunUntilIdle();
615 EXPECT_TRUE(listener.was_satisfied()); 615 EXPECT_TRUE(listener.was_satisfied());
616 } 616 }
617 617
618 IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
619 DontInjectContentScriptsInBackgroundPages) {
620 host_resolver()->AddRule("a.com", "127.0.0.1");
621 ASSERT_TRUE(StartEmbeddedTestServer());
622 // Load two extensions, one with an iframe to a.com in its background page,
623 // the other, a content script for a.com. The latter should never be able to
624 // inject the script, because scripts aren't allowed to run on foreign
625 // extensions' pages.
626 base::FilePath data_dir = test_data_dir_.AppendASCII("content_scripts");
627 ExtensionTestMessageListener iframe_loaded_listener("iframe loaded", false);
628 ExtensionTestMessageListener content_script_listener("script injected",
629 false);
630 LoadExtension(data_dir.AppendASCII("script_a_com"));
631 LoadExtension(data_dir.AppendASCII("background_page_iframe"));
632 iframe_loaded_listener.WaitUntilSatisfied();
633 EXPECT_FALSE(content_script_listener.was_satisfied());
634 }
635
618 } // namespace extensions 636 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/content_scripts/background_page_iframe/background.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698