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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/crx_installer.h" | 10 #include "chrome/browser/extensions/crx_installer.h" |
11 #include "chrome/browser/extensions/extension_browsertest.h" | 11 #include "chrome/browser/extensions/extension_browsertest.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/plugin_service.h" | 19 #include "content/public/browser/plugin_service.h" |
20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
21 #include "content/public/common/webplugininfo.h" | 21 #include "content/public/common/webplugininfo.h" |
22 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
23 #include "extensions/browser/extension_system.h" | 23 #include "extensions/browser/extension_system.h" |
24 #include "net/dns/mock_host_resolver.h" | 24 #include "net/dns/mock_host_resolver.h" |
| 25 #include "net/test/embedded_test_server/embedded_test_server.h" |
25 | 26 |
26 using content::PluginService; | 27 using content::PluginService; |
27 using content::WebContents; | 28 using content::WebContents; |
28 using extensions::Extension; | 29 using extensions::Extension; |
29 using extensions::Manifest; | 30 using extensions::Manifest; |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 const char kExtensionId[] = "bjjcibdiodkkeanflmiijlcfieiemced"; | 34 const char kExtensionId[] = "bjjcibdiodkkeanflmiijlcfieiemced"; |
34 | 35 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 void CheckPluginsCreated(const Extension* extension, | 141 void CheckPluginsCreated(const Extension* extension, |
141 PluginType expected_to_succeed) { | 142 PluginType expected_to_succeed) { |
142 CheckPluginsCreated(extension->GetResourceURL("test.html"), | 143 CheckPluginsCreated(extension->GetResourceURL("test.html"), |
143 expected_to_succeed); | 144 expected_to_succeed); |
144 } | 145 } |
145 }; | 146 }; |
146 | 147 |
147 // Test that the NaCl plugin isn't blocked for Webstore extensions. | 148 // Test that the NaCl plugin isn't blocked for Webstore extensions. |
148 // Disabled: http://crbug.com/319892 | 149 // Disabled: http://crbug.com/319892 |
149 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_WebStoreExtension) { | 150 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_WebStoreExtension) { |
150 ASSERT_TRUE(test_server()->Start()); | 151 ASSERT_TRUE(embedded_test_server()->Start()); |
151 | 152 |
152 const Extension* extension = InstallExtension(INSTALL_TYPE_FROM_WEBSTORE); | 153 const Extension* extension = InstallExtension(INSTALL_TYPE_FROM_WEBSTORE); |
153 ASSERT_TRUE(extension); | 154 ASSERT_TRUE(extension); |
154 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL); | 155 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL); |
155 } | 156 } |
156 | 157 |
157 // Test that the NaCl plugin is blocked for non-Webstore extensions. | 158 // Test that the NaCl plugin is blocked for non-Webstore extensions. |
158 // Disabled: http://crbug.com/319892 | 159 // Disabled: http://crbug.com/319892 |
159 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_NonWebStoreExtension) { | 160 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_NonWebStoreExtension) { |
160 ASSERT_TRUE(test_server()->Start()); | 161 ASSERT_TRUE(embedded_test_server()->Start()); |
161 | 162 |
162 const Extension* extension = InstallExtension(INSTALL_TYPE_NON_WEBSTORE); | 163 const Extension* extension = InstallExtension(INSTALL_TYPE_NON_WEBSTORE); |
163 ASSERT_TRUE(extension); | 164 ASSERT_TRUE(extension); |
164 CheckPluginsCreated(extension, PLUGIN_TYPE_NONE); | 165 CheckPluginsCreated(extension, PLUGIN_TYPE_NONE); |
165 } | 166 } |
166 | 167 |
167 // Test that the NaCl plugin isn't blocked for component extensions. | 168 // Test that the NaCl plugin isn't blocked for component extensions. |
168 // Disabled: http://crbug.com/319892 | 169 // Disabled: http://crbug.com/319892 |
169 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_ComponentExtension) { | 170 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_ComponentExtension) { |
170 ASSERT_TRUE(test_server()->Start()); | 171 ASSERT_TRUE(embedded_test_server()->Start()); |
171 | 172 |
172 const Extension* extension = InstallExtension(INSTALL_TYPE_COMPONENT); | 173 const Extension* extension = InstallExtension(INSTALL_TYPE_COMPONENT); |
173 ASSERT_TRUE(extension); | 174 ASSERT_TRUE(extension); |
174 ASSERT_EQ(extension->location(), Manifest::COMPONENT); | 175 ASSERT_EQ(extension->location(), Manifest::COMPONENT); |
175 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL); | 176 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL); |
176 } | 177 } |
177 | 178 |
178 // Test that the NaCl plugin isn't blocked for unpacked extensions. | 179 // Test that the NaCl plugin isn't blocked for unpacked extensions. |
179 // Disabled: http://crbug.com/319892 | 180 // Disabled: http://crbug.com/319892 |
180 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_UnpackedExtension) { | 181 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_UnpackedExtension) { |
181 ASSERT_TRUE(test_server()->Start()); | 182 ASSERT_TRUE(embedded_test_server()->Start()); |
182 | 183 |
183 const Extension* extension = InstallExtension(INSTALL_TYPE_UNPACKED); | 184 const Extension* extension = InstallExtension(INSTALL_TYPE_UNPACKED); |
184 ASSERT_TRUE(extension); | 185 ASSERT_TRUE(extension); |
185 ASSERT_EQ(extension->location(), Manifest::UNPACKED); | 186 ASSERT_EQ(extension->location(), Manifest::UNPACKED); |
186 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL); | 187 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL); |
187 } | 188 } |
188 | 189 |
189 // Test that the NaCl plugin is blocked for non chrome-extension urls, except | 190 // Test that the NaCl plugin is blocked for non chrome-extension urls, except |
190 // if it's a content (MIME type) handler. | 191 // if it's a content (MIME type) handler. |
191 // Disabled: http://crbug.com/319892 | 192 // Disabled: http://crbug.com/319892 |
192 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_NonExtensionScheme) { | 193 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_NonExtensionScheme) { |
193 ASSERT_TRUE(test_server()->Start()); | 194 ASSERT_TRUE(embedded_test_server()->Start()); |
194 | 195 |
195 const Extension* extension = InstallExtension(INSTALL_TYPE_FROM_WEBSTORE); | 196 const Extension* extension = InstallExtension(INSTALL_TYPE_FROM_WEBSTORE); |
196 ASSERT_TRUE(extension); | 197 ASSERT_TRUE(extension); |
197 CheckPluginsCreated( | 198 CheckPluginsCreated( |
198 test_server()->GetURL("files/extensions/native_client/test.html"), | 199 embedded_test_server()->GetURL("/extensions/native_client/test.html"), |
199 PLUGIN_TYPE_CONTENT_HANDLER); | 200 PLUGIN_TYPE_CONTENT_HANDLER); |
200 } | 201 } |
201 | 202 |
202 // Test that NaCl plugin isn't blocked for hosted app URLs. | 203 // Test that NaCl plugin isn't blocked for hosted app URLs. |
203 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, HostedApp) { | 204 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, HostedApp) { |
204 host_resolver()->AddRule("*", "127.0.0.1"); | 205 host_resolver()->AddRule("*", "127.0.0.1"); |
205 ASSERT_TRUE(test_server()->Start()); | 206 ASSERT_TRUE(embedded_test_server()->Start()); |
206 | 207 |
207 GURL url = test_server()->GetURL("files/extensions/native_client/test.html"); | 208 GURL url = |
| 209 embedded_test_server()->GetURL("/extensions/native_client/test.html"); |
208 GURL::Replacements replace_host; | 210 GURL::Replacements replace_host; |
209 replace_host.SetHostStr("localhost"); | 211 replace_host.SetHostStr("localhost"); |
210 replace_host.ClearPort(); | 212 replace_host.ClearPort(); |
211 url = url.ReplaceComponents(replace_host); | 213 url = url.ReplaceComponents(replace_host); |
212 | 214 |
213 const Extension* extension = InstallHostedApp(); | 215 const Extension* extension = InstallHostedApp(); |
214 ASSERT_TRUE(extension); | 216 ASSERT_TRUE(extension); |
215 CheckPluginsCreated(url, PLUGIN_TYPE_ALL); | 217 CheckPluginsCreated(url, PLUGIN_TYPE_ALL); |
216 } | 218 } |
217 | 219 |
218 } // namespace | 220 } // namespace |
OLD | NEW |