OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/frame_host/navigation_handle_impl.h" | 10 #include "content/browser/frame_host/navigation_handle_impl.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 ASSERT_TRUE(root->navigation_request()); | 315 ASSERT_TRUE(root->navigation_request()); |
316 EXPECT_EQ(GURL(), | 316 EXPECT_EQ(GURL(), |
317 root->navigation_request()->navigation_handle()->GetReferrer().url); | 317 root->navigation_request()->navigation_handle()->GetReferrer().url); |
318 | 318 |
319 // The navigation should commit without being blocked. | 319 // The navigation should commit without being blocked. |
320 EXPECT_TRUE(manager.WaitForResponse()); | 320 EXPECT_TRUE(manager.WaitForResponse()); |
321 manager.WaitForNavigationFinished(); | 321 manager.WaitForNavigationFinished(); |
322 EXPECT_EQ(kInsecureUrl, shell()->web_contents()->GetLastCommittedURL()); | 322 EXPECT_EQ(kInsecureUrl, shell()->web_contents()->GetLastCommittedURL()); |
323 } | 323 } |
324 | 324 |
| 325 // Test case to verify that redirects to data: URLs are properly disallowed, |
| 326 // even when invoked through a reload. |
| 327 // See https://crbug.com/723796. |
| 328 // |
| 329 // Note: This is PlzNavigate specific test, as the behavior of reloads in the |
| 330 // non-PlzNavigate path differs. The WebURLRequest for the reload is generated |
| 331 // based on Blink's state instead of the history state in the browser process, |
| 332 // which ends up loading the originally blocked URL. With PlzNavigate, the |
| 333 // reload uses the NavigationEntry state to create a navigation and commit it. |
| 334 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, |
| 335 VerifyBlockedErrorPageURL_Reload) { |
| 336 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( |
| 337 shell()->web_contents()->GetController()); |
| 338 |
| 339 GURL start_url(embedded_test_server()->GetURL("/title1.html")); |
| 340 EXPECT_TRUE(NavigateToURL(shell(), start_url)); |
| 341 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 342 |
| 343 // Navigate to an URL, which redirects to a data: URL, since it is an |
| 344 // unsafe redirect and will result in a blocked navigation and error page. |
| 345 GURL redirect_to_blank_url( |
| 346 embedded_test_server()->GetURL("/server-redirect?data:text/html,Hello!")); |
| 347 EXPECT_FALSE(NavigateToURL(shell(), redirect_to_blank_url)); |
| 348 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 349 EXPECT_EQ(PAGE_TYPE_ERROR, controller.GetLastCommittedEntry()->GetPageType()); |
| 350 |
| 351 TestNavigationObserver reload_observer(shell()->web_contents()); |
| 352 EXPECT_TRUE(ExecuteScript(shell(), "location.reload()")); |
| 353 reload_observer.Wait(); |
| 354 |
| 355 // The expectation is that about:blank was loaded and the virtual URL is set |
| 356 // to the URL that was blocked. |
| 357 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 358 EXPECT_FALSE( |
| 359 controller.GetLastCommittedEntry()->GetURL().SchemeIs(url::kDataScheme)); |
| 360 EXPECT_TRUE(controller.GetLastCommittedEntry()->GetVirtualURL().SchemeIs( |
| 361 url::kDataScheme)); |
| 362 EXPECT_EQ(url::kAboutBlankURL, |
| 363 controller.GetLastCommittedEntry()->GetURL().spec()); |
| 364 } |
| 365 |
325 } // namespace content | 366 } // namespace content |
OLD | NEW |