OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
7 #include "chrome/browser/extensions/extension_test_message_listener.h" | 7 #include "chrome/browser/extensions/extension_test_message_listener.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 false); | 76 false); |
77 ExtensionTestMessageListener listener5b("execute: " + page_url.spec(), false); | 77 ExtensionTestMessageListener listener5b("execute: " + page_url.spec(), false); |
78 ui_test_utils::NavigateToURL(browser(), page_url); | 78 ui_test_utils::NavigateToURL(browser(), page_url); |
79 ASSERT_TRUE(listener5a.WaitUntilSatisfied()); | 79 ASSERT_TRUE(listener5a.WaitUntilSatisfied()); |
80 ASSERT_TRUE(listener5b.WaitUntilSatisfied()); | 80 ASSERT_TRUE(listener5b.WaitUntilSatisfied()); |
81 } | 81 } |
82 | 82 |
83 // Test that an extension NOT whitelisted for scripting can ask for <all_urls> | 83 // Test that an extension NOT whitelisted for scripting can ask for <all_urls> |
84 // and run scripts on non-restricted all pages. | 84 // and run scripts on non-restricted all pages. |
85 IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, RegularExtensions) { | 85 IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, RegularExtensions) { |
86 // First load the two extension. | 86 // First load the two extensions. |
87 FilePath extension_dir1 = test_data_dir_.AppendASCII("all_urls") | 87 FilePath extension_dir1 = test_data_dir_.AppendASCII("all_urls") |
88 .AppendASCII("content_script"); | 88 .AppendASCII("content_script"); |
89 FilePath extension_dir2 = test_data_dir_.AppendASCII("all_urls") | 89 FilePath extension_dir2 = test_data_dir_.AppendASCII("all_urls") |
90 .AppendASCII("execute_script"); | 90 .AppendASCII("execute_script"); |
91 | 91 |
92 | 92 |
93 ExtensionService* service = browser()->profile()->GetExtensionService(); | 93 ExtensionService* service = browser()->profile()->GetExtensionService(); |
94 const size_t size_before = service->extensions()->size(); | 94 const size_t size_before = service->extensions()->size(); |
95 ASSERT_TRUE(LoadExtension(extension_dir1)); | 95 ASSERT_TRUE(LoadExtension(extension_dir1)); |
96 ASSERT_TRUE(LoadExtension(extension_dir2)); | 96 ASSERT_TRUE(LoadExtension(extension_dir2)); |
97 EXPECT_EQ(size_before + 2, service->extensions()->size()); | 97 EXPECT_EQ(size_before + 2, service->extensions()->size()); |
98 | 98 |
99 // Now verify we can script a regular http page. | 99 // Now verify we can script a regular http page. |
100 ASSERT_TRUE(test_server()->Start()); | 100 ASSERT_TRUE(test_server()->Start()); |
101 GURL page_url = test_server()->GetURL(kAllUrlsTarget); | 101 GURL page_url = test_server()->GetURL(kAllUrlsTarget); |
102 ExtensionTestMessageListener listener1a("content script: " + page_url.spec(), | 102 ExtensionTestMessageListener listener1a("content script: " + page_url.spec(), |
103 false); | 103 false); |
104 ExtensionTestMessageListener listener1b("execute: " + page_url.spec(), false); | 104 ExtensionTestMessageListener listener1b("execute: " + page_url.spec(), false); |
105 ui_test_utils::NavigateToURL(browser(), page_url); | 105 ui_test_utils::NavigateToURL(browser(), page_url); |
106 ASSERT_TRUE(listener1a.WaitUntilSatisfied()); | 106 ASSERT_TRUE(listener1a.WaitUntilSatisfied()); |
107 ASSERT_TRUE(listener1b.WaitUntilSatisfied()); | 107 ASSERT_TRUE(listener1b.WaitUntilSatisfied()); |
108 } | 108 } |
OLD | NEW |