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

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

Issue 9909019: Add schema chrome-extension-resource:// for extension resources (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update Created 8 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/logging.h" 5 #include "base/logging.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/common/chrome_switches.h" 8 #include "chrome/common/chrome_switches.h"
9 #include "chrome/test/base/ui_test_utils.h" 9 #include "chrome/test/base/ui_test_utils.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "net/base/mock_host_resolver.h" 12 #include "net/base/mock_host_resolver.h"
13 13
14 class ExtensionResourceRequestPolicyTest : public ExtensionApiTest { 14 class ExtensionResourceRequestPolicyTest : public ExtensionApiTest {
15 protected: 15 protected:
16 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 16 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
17 ExtensionApiTest::SetUpCommandLine(command_line); 17 ExtensionApiTest::SetUpCommandLine(command_line);
18 command_line->AppendSwitch(switches::kAllowLegacyExtensionManifests); 18 command_line->AppendSwitch(switches::kAllowLegacyExtensionManifests);
19 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
20 command_line->AppendSwitch(switches::kEnablePlatformApps);
19 } 21 }
20 }; 22 };
21 23
22 // Note, this mostly tests the logic of chrome/renderer/extensions/ 24 // Note, this mostly tests the logic of chrome/renderer/extensions/
23 // extension_resource_request_policy.*, but we have it as a browser test so that 25 // extension_resource_request_policy.*, but we have it as a browser test so that
24 // can make sure it works end-to-end. 26 // can make sure it works end-to-end.
25 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, OriginPrivileges) { 27 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, OriginPrivileges) {
26 host_resolver()->AddRule("*", "127.0.0.1"); 28 host_resolver()->AddRule("*", "127.0.0.1");
27 ASSERT_TRUE(test_server()->Start()); 29 ASSERT_TRUE(test_server()->Start());
28 ASSERT_TRUE(LoadExtension(test_data_dir_ 30 ASSERT_TRUE(LoadExtension(test_data_dir_
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 GURL nonexistent_resource( 188 GURL nonexistent_resource(
187 test_server()->GetURL( 189 test_server()->GetURL(
188 "files/extensions/api_test/extension_resource_request_policy/" 190 "files/extensions/api_test/extension_resource_request_policy/"
189 "web_accessible/nonexistent_resource.html")); 191 "web_accessible/nonexistent_resource.html"));
190 ui_test_utils::NavigateToURL(browser(), nonexistent_resource); 192 ui_test_utils::NavigateToURL(browser(), nonexistent_resource);
191 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 193 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
192 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", 194 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
193 L"window.domAutomationController.send(document.title)", 195 L"window.domAutomationController.send(document.title)",
194 &result)); 196 &result));
195 EXPECT_EQ("Image failed to load", result); 197 EXPECT_EQ("Image failed to load", result);
198
199 GURL nonaccessabile_cer_resource(
200 test_server()->GetURL(
201 "files/extensions/api_test/extension_resource_request_policy/"
202 "web_accessible/nonaccessabile_chrome_resource_scheme.html"));
Mihai Parparita -not on Chrome 2012/05/16 23:17:44 Typo ("nonaccessabile")
Peng 2012/05/17 14:49:57 Done.
203 ui_test_utils::NavigateToURL(browser(), nonaccessabile_cer_resource);
204 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
205 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
206 L"window.domAutomationController.send(document.title)",
207 &result));
208 EXPECT_EQ("Loading CER:// failed.", result);
196 } 209 }
197 210
198 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, Iframe) { 211 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, Iframe) {
199 // Load another extension, which the test one shouldn't be able to get 212 // Load another extension, which the test one shouldn't be able to get
200 // resources from. 213 // resources from.
201 ASSERT_TRUE(LoadExtension(test_data_dir_ 214 ASSERT_TRUE(LoadExtension(test_data_dir_
202 .AppendASCII("extension_resource_request_policy") 215 .AppendASCII("extension_resource_request_policy")
203 .AppendASCII("inaccessible"))); 216 .AppendASCII("inaccessible")));
204 EXPECT_TRUE(RunExtensionSubtest( 217 EXPECT_TRUE(RunExtensionSubtest(
205 "extension_resource_request_policy/web_accessible", 218 "extension_resource_request_policy/web_accessible",
206 "iframe.html")); 219 "iframe.html"));
207 } 220 }
221
222 #if defined(OS_WIN)
Mihai Parparita -not on Chrome 2012/05/16 23:17:44 Why is this disabled on Windows?
Peng 2012/05/17 14:49:57 Done
223 #define MAYBE_ExtensionAccessibleResources DISABLED_ExtensionAccessibleResources
224 #else
225 #define MAYBE_ExtensionAccessibleResources ExtensionAccessibleResources
226 #endif
227 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest,
228 MAYBE_ExtensionAccessibleResources) {
229 ASSERT_TRUE(RunExtensionSubtest("accessible_cer", "main.html")) << message_;
230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698