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

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

Issue 2847313002: Update some host_resolver()->AddRules in chrome/browser. (Closed)
Patch Set: Created 3 years, 7 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
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/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/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/crx_installer.h" 9 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
(...skipping 21 matching lines...) Expand all
32 namespace { 32 namespace {
33 33
34 const char kExtensionId[] = "bjjcibdiodkkeanflmiijlcfieiemced"; 34 const char kExtensionId[] = "bjjcibdiodkkeanflmiijlcfieiemced";
35 35
36 // This class tests that the Native Client plugin is blocked unless the 36 // This class tests that the Native Client plugin is blocked unless the
37 // .nexe is part of an extension from the Chrome Webstore. 37 // .nexe is part of an extension from the Chrome Webstore.
38 class NaClExtensionTest : public ExtensionBrowserTest { 38 class NaClExtensionTest : public ExtensionBrowserTest {
39 public: 39 public:
40 NaClExtensionTest() {} 40 NaClExtensionTest() {}
41 41
42 void SetUpOnMainThread() override {
43 ExtensionBrowserTest::SetUpOnMainThread();
44 host_resolver()->AddRule("*", "127.0.0.1");
45 ASSERT_TRUE(embedded_test_server()->Start());
46 }
47
42 protected: 48 protected:
43 enum InstallType { 49 enum InstallType {
44 INSTALL_TYPE_COMPONENT, 50 INSTALL_TYPE_COMPONENT,
45 INSTALL_TYPE_UNPACKED, 51 INSTALL_TYPE_UNPACKED,
46 INSTALL_TYPE_FROM_WEBSTORE, 52 INSTALL_TYPE_FROM_WEBSTORE,
47 INSTALL_TYPE_NON_WEBSTORE, 53 INSTALL_TYPE_NON_WEBSTORE,
48 }; 54 };
49 enum PluginType { 55 enum PluginType {
50 PLUGIN_TYPE_NONE = 0, 56 PLUGIN_TYPE_NONE = 0,
51 PLUGIN_TYPE_EMBED = 1, 57 PLUGIN_TYPE_EMBED = 1,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void CheckPluginsCreated(const Extension* extension, 147 void CheckPluginsCreated(const Extension* extension,
142 PluginType expected_to_succeed) { 148 PluginType expected_to_succeed) {
143 CheckPluginsCreated(extension->GetResourceURL("test.html"), 149 CheckPluginsCreated(extension->GetResourceURL("test.html"),
144 expected_to_succeed); 150 expected_to_succeed);
145 } 151 }
146 }; 152 };
147 153
148 // Test that the NaCl plugin isn't blocked for Webstore extensions. 154 // Test that the NaCl plugin isn't blocked for Webstore extensions.
149 // Disabled: http://crbug.com/319892 155 // Disabled: http://crbug.com/319892
150 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_WebStoreExtension) { 156 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_WebStoreExtension) {
151 ASSERT_TRUE(embedded_test_server()->Start());
152
153 const Extension* extension = InstallExtension(INSTALL_TYPE_FROM_WEBSTORE); 157 const Extension* extension = InstallExtension(INSTALL_TYPE_FROM_WEBSTORE);
154 ASSERT_TRUE(extension); 158 ASSERT_TRUE(extension);
155 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL); 159 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL);
156 } 160 }
157 161
158 // Test that the NaCl plugin is blocked for non-Webstore extensions. 162 // Test that the NaCl plugin is blocked for non-Webstore extensions.
159 // Disabled: http://crbug.com/319892 163 // Disabled: http://crbug.com/319892
160 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_NonWebStoreExtension) { 164 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_NonWebStoreExtension) {
161 ASSERT_TRUE(embedded_test_server()->Start());
162
163 const Extension* extension = InstallExtension(INSTALL_TYPE_NON_WEBSTORE); 165 const Extension* extension = InstallExtension(INSTALL_TYPE_NON_WEBSTORE);
164 ASSERT_TRUE(extension); 166 ASSERT_TRUE(extension);
165 CheckPluginsCreated(extension, PLUGIN_TYPE_NONE); 167 CheckPluginsCreated(extension, PLUGIN_TYPE_NONE);
166 } 168 }
167 169
168 // Test that the NaCl plugin isn't blocked for component extensions. 170 // Test that the NaCl plugin isn't blocked for component extensions.
169 // Disabled: http://crbug.com/319892 171 // Disabled: http://crbug.com/319892
170 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_ComponentExtension) { 172 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_ComponentExtension) {
171 ASSERT_TRUE(embedded_test_server()->Start());
172
173 const Extension* extension = InstallExtension(INSTALL_TYPE_COMPONENT); 173 const Extension* extension = InstallExtension(INSTALL_TYPE_COMPONENT);
174 ASSERT_TRUE(extension); 174 ASSERT_TRUE(extension);
175 ASSERT_EQ(extension->location(), Manifest::COMPONENT); 175 ASSERT_EQ(extension->location(), Manifest::COMPONENT);
176 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL); 176 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL);
177 } 177 }
178 178
179 // Test that the NaCl plugin isn't blocked for unpacked extensions. 179 // Test that the NaCl plugin isn't blocked for unpacked extensions.
180 // Disabled: http://crbug.com/319892 180 // Disabled: http://crbug.com/319892
181 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_UnpackedExtension) { 181 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_UnpackedExtension) {
182 ASSERT_TRUE(embedded_test_server()->Start());
183
184 const Extension* extension = InstallExtension(INSTALL_TYPE_UNPACKED); 182 const Extension* extension = InstallExtension(INSTALL_TYPE_UNPACKED);
185 ASSERT_TRUE(extension); 183 ASSERT_TRUE(extension);
186 ASSERT_EQ(extension->location(), Manifest::UNPACKED); 184 ASSERT_EQ(extension->location(), Manifest::UNPACKED);
187 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL); 185 CheckPluginsCreated(extension, PLUGIN_TYPE_ALL);
188 } 186 }
189 187
190 // Test that the NaCl plugin is blocked for non chrome-extension urls, except 188 // Test that the NaCl plugin is blocked for non chrome-extension urls, except
191 // if it's a content (MIME type) handler. 189 // if it's a content (MIME type) handler.
192 // Disabled: http://crbug.com/319892 190 // Disabled: http://crbug.com/319892
193 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_NonExtensionScheme) { 191 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, DISABLED_NonExtensionScheme) {
194 ASSERT_TRUE(embedded_test_server()->Start());
195
196 const Extension* extension = InstallExtension(INSTALL_TYPE_FROM_WEBSTORE); 192 const Extension* extension = InstallExtension(INSTALL_TYPE_FROM_WEBSTORE);
197 ASSERT_TRUE(extension); 193 ASSERT_TRUE(extension);
198 CheckPluginsCreated( 194 CheckPluginsCreated(
199 embedded_test_server()->GetURL("/extensions/native_client/test.html"), 195 embedded_test_server()->GetURL("/extensions/native_client/test.html"),
200 PLUGIN_TYPE_CONTENT_HANDLER); 196 PLUGIN_TYPE_CONTENT_HANDLER);
201 } 197 }
202 198
203 // Test that NaCl plugin isn't blocked for hosted app URLs. 199 // Test that NaCl plugin isn't blocked for hosted app URLs.
204 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, HostedApp) { 200 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, HostedApp) {
205 host_resolver()->AddRule("*", "127.0.0.1");
206 ASSERT_TRUE(embedded_test_server()->Start());
207
208 GURL url = 201 GURL url =
209 embedded_test_server()->GetURL("/extensions/native_client/test.html"); 202 embedded_test_server()->GetURL("/extensions/native_client/test.html");
210 GURL::Replacements replace_host; 203 GURL::Replacements replace_host;
211 replace_host.SetHostStr("localhost"); 204 replace_host.SetHostStr("localhost");
212 replace_host.ClearPort(); 205 replace_host.ClearPort();
213 url = url.ReplaceComponents(replace_host); 206 url = url.ReplaceComponents(replace_host);
214 207
215 const Extension* extension = InstallHostedApp(); 208 const Extension* extension = InstallHostedApp();
216 ASSERT_TRUE(extension); 209 ASSERT_TRUE(extension);
217 CheckPluginsCreated(url, PLUGIN_TYPE_ALL); 210 CheckPluginsCreated(url, PLUGIN_TYPE_ALL);
218 } 211 }
219 212
220 } // namespace 213 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_messages_apitest.cc ('k') | chrome/browser/extensions/extension_override_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698