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/strings/utf_string_conversions.h" | 5 #include "base/strings/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/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 #include "content/public/test/browser_test_utils.h" | 16 #include "content/public/test/browser_test_utils.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
| 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
19 | 20 |
20 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { | 21 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) { |
21 ASSERT_TRUE(StartTestServer()); | 22 ASSERT_TRUE(StartTestServer()); |
22 ASSERT_TRUE(RunExtensionTest("content_scripts/all_frames")) << message_; | 23 ASSERT_TRUE(RunExtensionTest("content_scripts/all_frames")) << message_; |
23 } | 24 } |
24 | 25 |
25 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAboutBlankIframes) { | 26 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAboutBlankIframes) { |
26 ASSERT_TRUE(StartTestServer()); | 27 ASSERT_TRUE(StartTestServer()); |
27 ASSERT_TRUE( | 28 ASSERT_TRUE( |
28 RunExtensionTest("content_scripts/about_blank_iframes")) << message_; | 29 RunExtensionTest("content_scripts/about_blank_iframes")) << message_; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 127 } |
127 | 128 |
128 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptExtensionAPIs) { | 129 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptExtensionAPIs) { |
129 ASSERT_TRUE(StartTestServer()); | 130 ASSERT_TRUE(StartTestServer()); |
130 | 131 |
131 const extensions::Extension* extension = LoadExtension( | 132 const extensions::Extension* extension = LoadExtension( |
132 test_data_dir_.AppendASCII("content_scripts/extension_api")); | 133 test_data_dir_.AppendASCII("content_scripts/extension_api")); |
133 | 134 |
134 ResultCatcher catcher; | 135 ResultCatcher catcher; |
135 ui_test_utils::NavigateToURL( | 136 ui_test_utils::NavigateToURL( |
136 browser(), test_server()->GetURL("functions.html")); | 137 browser(), |
| 138 embedded_test_server()->GetURL( |
| 139 "/extensions/api_test/content_scripts/extension_api/functions.html")); |
137 EXPECT_TRUE(catcher.GetNextResult()); | 140 EXPECT_TRUE(catcher.GetNextResult()); |
138 | 141 |
139 // Navigate to a page that will cause a content script to run that starts | 142 // Navigate to a page that will cause a content script to run that starts |
140 // listening for an extension event. | 143 // listening for an extension event. |
141 ui_test_utils::NavigateToURL( | 144 ui_test_utils::NavigateToURL( |
142 browser(), test_server()->GetURL("events.html")); | 145 browser(), |
| 146 embedded_test_server()->GetURL( |
| 147 "/extensions/api_test/content_scripts/extension_api/events.html")); |
143 | 148 |
144 // Navigate to an extension page that will fire the event events.js is | 149 // Navigate to an extension page that will fire the event events.js is |
145 // listening for. | 150 // listening for. |
146 ui_test_utils::NavigateToURLWithDisposition( | 151 ui_test_utils::NavigateToURLWithDisposition( |
147 browser(), extension->GetResourceURL("fire_event.html"), | 152 browser(), extension->GetResourceURL("fire_event.html"), |
148 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_NONE); | 153 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_NONE); |
149 EXPECT_TRUE(catcher.GetNextResult()); | 154 EXPECT_TRUE(catcher.GetNextResult()); |
150 } | 155 } |
151 | 156 |
152 // Flaky on Windows. http://crbug.com/248418 | 157 // Flaky on Windows. http://crbug.com/248418 |
153 #if defined(OS_WIN) | 158 #if defined(OS_WIN) |
154 #define MAYBE_ContentScriptPermissionsApi DISABLED_ContentScriptPermissionsApi | 159 #define MAYBE_ContentScriptPermissionsApi DISABLED_ContentScriptPermissionsApi |
155 #else | 160 #else |
156 #define MAYBE_ContentScriptPermissionsApi ContentScriptPermissionsApi | 161 #define MAYBE_ContentScriptPermissionsApi ContentScriptPermissionsApi |
157 #endif | 162 #endif |
158 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_ContentScriptPermissionsApi) { | 163 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_ContentScriptPermissionsApi) { |
159 extensions::PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); | 164 extensions::PermissionsRequestFunction::SetIgnoreUserGestureForTests(true); |
160 extensions::PermissionsRequestFunction::SetAutoConfirmForTests(true); | 165 extensions::PermissionsRequestFunction::SetAutoConfirmForTests(true); |
161 host_resolver()->AddRule("*.com", "127.0.0.1"); | 166 host_resolver()->AddRule("*.com", "127.0.0.1"); |
162 ASSERT_TRUE(StartTestServer()); | 167 ASSERT_TRUE(StartTestServer()); |
163 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; | 168 ASSERT_TRUE(RunExtensionTest("content_scripts/permissions")) << message_; |
164 } | 169 } |
165 | 170 |
166 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptBypassPageCSP) { | 171 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptBypassPageCSP) { |
167 ASSERT_TRUE(StartTestServer()); | 172 ASSERT_TRUE(StartTestServer()); |
168 ASSERT_TRUE(RunExtensionTest("content_scripts/bypass_page_csp")) << message_; | 173 ASSERT_TRUE(RunExtensionTest("content_scripts/bypass_page_csp")) << message_; |
169 } | 174 } |
OLD | NEW |