| 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" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/test/base/test_switches.h" | 12 #include "chrome/test/base/test_switches.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "content/public/browser/navigation_handle.h" | 14 #include "content/public/browser/navigation_handle.h" |
| 15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "content/public/common/browser_side_navigation_policy.h" |
| 18 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
| 19 #include "extensions/common/switches.h" | 20 #include "extensions/common/switches.h" |
| 20 #include "net/dns/mock_host_resolver.h" | 21 #include "net/dns/mock_host_resolver.h" |
| 21 #include "net/test/embedded_test_server/embedded_test_server.h" | 22 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 23 | 24 |
| 24 class ExtensionResourceRequestPolicyTest : public ExtensionApiTest { | 25 class ExtensionResourceRequestPolicyTest : public ExtensionApiTest { |
| 25 protected: | 26 protected: |
| 26 void SetUpCommandLine(base::CommandLine* command_line) override { | 27 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 27 ExtensionApiTest::SetUpCommandLine(command_line); | 28 ExtensionApiTest::SetUpCommandLine(command_line); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 browser(), accessible_linked_resource, 1); | 249 browser(), accessible_linked_resource, 1); |
| 249 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 250 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 250 browser()->tab_strip_model()->GetActiveWebContents(), | 251 browser()->tab_strip_model()->GetActiveWebContents(), |
| 251 "window.domAutomationController.send(document.URL)", | 252 "window.domAutomationController.send(document.URL)", |
| 252 &result)); | 253 &result)); |
| 253 EXPECT_NE("about:blank", result); | 254 EXPECT_NE("about:blank", result); |
| 254 | 255 |
| 255 GURL nonaccessible_linked_resource(embedded_test_server()->GetURL( | 256 GURL nonaccessible_linked_resource(embedded_test_server()->GetURL( |
| 256 "/extensions/api_test/extension_resource_request_policy/" | 257 "/extensions/api_test/extension_resource_request_policy/" |
| 257 "web_accessible/nonaccessible_link_resource.html")); | 258 "web_accessible/nonaccessible_link_resource.html")); |
| 259 // With PlzNavigate, the first DidStopLoading IPC is dropped because loading |
| 260 // is delayed until the beforeunload handler ACK comes back. |
| 258 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), | 261 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), |
| 259 nonaccessible_linked_resource, 2); | 262 nonaccessible_linked_resource, |
| 263 content::IsBrowserSideNavigationEnabled() ? 1 : 2); |
| 260 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 264 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 261 browser()->tab_strip_model()->GetActiveWebContents(), | 265 browser()->tab_strip_model()->GetActiveWebContents(), |
| 262 "window.domAutomationController.send(document.URL)", | 266 "window.domAutomationController.send(document.URL)", |
| 263 &result)); | 267 &result)); |
| 264 EXPECT_EQ("about:blank", result); | 268 EXPECT_EQ("about:blank", result); |
| 265 | 269 |
| 266 | 270 |
| 267 // Redirects can sometimes occur before the load event, so use a | 271 // Redirects can sometimes occur before the load event, so use a |
| 268 // UrlLoadObserver instead of blocking waiting for two load events. | 272 // UrlLoadObserver instead of blocking waiting for two load events. |
| 269 GURL accessible_url = extension->GetResourceURL("/test.png"); | 273 GURL accessible_url = extension->GetResourceURL("/test.png"); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 385 |
| 382 content::WebContents* web_contents = | 386 content::WebContents* web_contents = |
| 383 browser()->tab_strip_model()->GetActiveWebContents(); | 387 browser()->tab_strip_model()->GetActiveWebContents(); |
| 384 | 388 |
| 385 GURL private_page( | 389 GURL private_page( |
| 386 "chrome-extension://kegmjfcnjamahdnldjmlpachmpielcdk/private.html"); | 390 "chrome-extension://kegmjfcnjamahdnldjmlpachmpielcdk/private.html"); |
| 387 NavigationErrorObserver observer(web_contents, private_page); | 391 NavigationErrorObserver observer(web_contents, private_page); |
| 388 ASSERT_TRUE(content::ExecuteScript(web_contents, "navigateFrameNow()")); | 392 ASSERT_TRUE(content::ExecuteScript(web_contents, "navigateFrameNow()")); |
| 389 observer.Wait(); | 393 observer.Wait(); |
| 390 } | 394 } |
| OLD | NEW |