| 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/logging.h" | 6 #include "base/logging.h" |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.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" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 GURL nonexistent_resource(embedded_test_server()->GetURL( | 202 GURL nonexistent_resource(embedded_test_server()->GetURL( |
| 203 "/extensions/api_test/extension_resource_request_policy/" | 203 "/extensions/api_test/extension_resource_request_policy/" |
| 204 "web_accessible/nonexistent_resource.html")); | 204 "web_accessible/nonexistent_resource.html")); |
| 205 ui_test_utils::NavigateToURL(browser(), nonexistent_resource); | 205 ui_test_utils::NavigateToURL(browser(), nonexistent_resource); |
| 206 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 206 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 207 browser()->tab_strip_model()->GetActiveWebContents(), | 207 browser()->tab_strip_model()->GetActiveWebContents(), |
| 208 "window.domAutomationController.send(document.title)", | 208 "window.domAutomationController.send(document.title)", |
| 209 &result)); | 209 &result)); |
| 210 EXPECT_EQ("Image failed to load", result); | 210 EXPECT_EQ("Image failed to load", result); |
| 211 | 211 |
| 212 GURL nonaccessible_cer_resource(embedded_test_server()->GetURL( | |
| 213 "/extensions/api_test/extension_resource_request_policy/" | |
| 214 "web_accessible/nonaccessible_chrome_resource_scheme.html")); | |
| 215 ui_test_utils::NavigateToURL(browser(), nonaccessible_cer_resource); | |
| 216 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | |
| 217 browser()->tab_strip_model()->GetActiveWebContents(), | |
| 218 "window.domAutomationController.send(document.title)", | |
| 219 &result)); | |
| 220 EXPECT_EQ("Loading CER:// failed.", result); | |
| 221 | |
| 222 GURL newtab_page("chrome://newtab"); | 212 GURL newtab_page("chrome://newtab"); |
| 223 GURL accessible_newtab_override(embedded_test_server()->GetURL( | 213 GURL accessible_newtab_override(embedded_test_server()->GetURL( |
| 224 "/extensions/api_test/extension_resource_request_policy/" | 214 "/extensions/api_test/extension_resource_request_policy/" |
| 225 "web_accessible/accessible_history_navigation.html")); | 215 "web_accessible/accessible_history_navigation.html")); |
| 226 ui_test_utils::NavigateToURL(browser(), newtab_page); | 216 ui_test_utils::NavigateToURL(browser(), newtab_page); |
| 227 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 217 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| 228 browser(), accessible_newtab_override, 1); | 218 browser(), accessible_newtab_override, 1); |
| 229 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 219 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 230 browser()->tab_strip_model()->GetActiveWebContents(), | 220 browser()->tab_strip_model()->GetActiveWebContents(), |
| 231 "window.domAutomationController.send(document.title)", | 221 "window.domAutomationController.send(document.title)", |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // Load another extension, which the test one shouldn't be able to get | 310 // Load another extension, which the test one shouldn't be able to get |
| 321 // resources from. | 311 // resources from. |
| 322 ASSERT_TRUE(LoadExtension(test_data_dir_ | 312 ASSERT_TRUE(LoadExtension(test_data_dir_ |
| 323 .AppendASCII("extension_resource_request_policy") | 313 .AppendASCII("extension_resource_request_policy") |
| 324 .AppendASCII("inaccessible"))); | 314 .AppendASCII("inaccessible"))); |
| 325 EXPECT_TRUE(RunExtensionSubtest( | 315 EXPECT_TRUE(RunExtensionSubtest( |
| 326 "extension_resource_request_policy/web_accessible", | 316 "extension_resource_request_policy/web_accessible", |
| 327 "iframe.html")) << message_; | 317 "iframe.html")) << message_; |
| 328 } | 318 } |
| 329 | 319 |
| 330 #if defined(OS_MACOSX) | |
| 331 #define MAYBE_ExtensionAccessibleResources DISABLED_ExtensionAccessibleResources | |
| 332 #else | |
| 333 #define MAYBE_ExtensionAccessibleResources ExtensionAccessibleResources | |
| 334 #endif | |
| 335 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, | |
| 336 MAYBE_ExtensionAccessibleResources) { | |
| 337 ASSERT_TRUE(RunExtensionSubtest("accessible_cer", "main.html")) << message_; | |
| 338 } | |
| 339 | |
| 340 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, | 320 IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, |
| 341 IframeNavigateToInaccessible) { | 321 IframeNavigateToInaccessible) { |
| 342 ASSERT_TRUE(embedded_test_server()->Start()); | 322 ASSERT_TRUE(embedded_test_server()->Start()); |
| 343 ASSERT_TRUE(LoadExtension( | 323 ASSERT_TRUE(LoadExtension( |
| 344 test_data_dir_.AppendASCII("extension_resource_request_policy") | 324 test_data_dir_.AppendASCII("extension_resource_request_policy") |
| 345 .AppendASCII("some_accessible"))); | 325 .AppendASCII("some_accessible"))); |
| 346 | 326 |
| 347 GURL iframe_navigate_url(embedded_test_server()->GetURL( | 327 GURL iframe_navigate_url(embedded_test_server()->GetURL( |
| 348 "/extensions/api_test/extension_resource_request_policy/" | 328 "/extensions/api_test/extension_resource_request_policy/" |
| 349 "iframe_navigate.html")); | 329 "iframe_navigate.html")); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 366 // The iframe should not load |private_page|, which is not web-accessible. | 346 // The iframe should not load |private_page|, which is not web-accessible. |
| 367 // | 347 // |
| 368 // TODO(alexmos): The failure mode differs on whether or not | 348 // TODO(alexmos): The failure mode differs on whether or not |
| 369 // --isolate-extensions is used: if it is on, the request is canceled and we | 349 // --isolate-extensions is used: if it is on, the request is canceled and we |
| 370 // stay on public.html (see https://crbug.com/656752), and if it's off, the | 350 // stay on public.html (see https://crbug.com/656752), and if it's off, the |
| 371 // request is blocked in ExtensionNavigationThrottle, which loads an error | 351 // request is blocked in ExtensionNavigationThrottle, which loads an error |
| 372 // page into the iframe. This check handles both cases, but we should make | 352 // page into the iframe. This check handles both cases, but we should make |
| 373 // the check stricter once --isolate-extensions is on by default. | 353 // the check stricter once --isolate-extensions is on by default. |
| 374 EXPECT_NE("Private", content); | 354 EXPECT_NE("Private", content); |
| 375 } | 355 } |
| OLD | NEW |