OLD | NEW |
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 Loading... |
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 |
OLD | NEW |