| Index: content/browser/frame_host/navigation_handle_impl_browsertest.cc
|
| diff --git a/content/browser/frame_host/navigation_handle_impl_browsertest.cc b/content/browser/frame_host/navigation_handle_impl_browsertest.cc
|
| index 82f3c8cb4cfb2a5091ac7ecedee6bd85c1cf7639..5a8f794b8433cab61e665e5d01e59f15589ced4c 100644
|
| --- a/content/browser/frame_host/navigation_handle_impl_browsertest.cc
|
| +++ b/content/browser/frame_host/navigation_handle_impl_browsertest.cc
|
| @@ -1067,4 +1067,63 @@ IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest,
|
| }
|
| }
|
|
|
| +// Record and list the navigations that are started and finished.
|
| +class NavigationLogger : public WebContentsObserver {
|
| + public:
|
| + NavigationLogger(WebContents* web_contents)
|
| + : WebContentsObserver(web_contents) {}
|
| +
|
| + void DidStartNavigation(NavigationHandle* navigation_handle) override {
|
| + started_navigation_urls_.push_back(navigation_handle->GetURL());
|
| + }
|
| +
|
| + void DidFinishNavigation(NavigationHandle* navigation_handle) override {
|
| + finished_navigation_urls_.push_back(navigation_handle->GetURL());
|
| + }
|
| +
|
| + const std::vector<GURL>& GetStartedNavigationURLS() {
|
| + return started_navigation_urls_;
|
| + }
|
| + const std::vector<GURL>& GetFinishedNavigationURLS() {
|
| + return finished_navigation_urls_;
|
| + }
|
| +
|
| + private:
|
| + std::vector<GURL> started_navigation_urls_;
|
| + std::vector<GURL> finished_navigation_urls_;
|
| +};
|
| +
|
| +// There was a bug without PlzNavigate that happened when a navigation was
|
| +// blocked after a redirect. Blink didn't know about the redirect and tried
|
| +// to commit an error page to the post-redirect URL. The result was that the
|
| +// NavigationHandle was not found on the browser-side and a new NavigationHandle
|
| +// created for committing the error page. This test makes sure that only one
|
| +// NavigationHandle is used for committing the error page.
|
| +// See crbug.com/695421
|
| +IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, BlockedOnRedirect) {
|
| + const GURL kUrl = embedded_test_server()->GetURL("/title1.html");
|
| + const GURL kRedirectingUrl =
|
| + embedded_test_server()->GetURL("/server-redirect?" + kUrl.spec());
|
| +
|
| + // Set up a NavigationThrottle that will block the navigation in
|
| + // WillRedirectRequest.
|
| + TestNavigationThrottleInstaller installer(
|
| + shell()->web_contents(), NavigationThrottle::PROCEED,
|
| + NavigationThrottle::BLOCK_REQUEST, NavigationThrottle::PROCEED);
|
| + NavigationHandleObserver observer(shell()->web_contents(), kRedirectingUrl);
|
| + NavigationLogger logger(shell()->web_contents());
|
| +
|
| + // Try to navigate to the url. The navigation should be canceled and the
|
| + // NavigationHandle should have the right error code.
|
| + EXPECT_FALSE(NavigateToURL(shell(), kRedirectingUrl));
|
| + EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, observer.net_error_code());
|
| +
|
| + // Only one navigation is expected to happen.
|
| + std::vector<GURL> started_navigation = {kRedirectingUrl};
|
| + EXPECT_EQ(started_navigation, logger.GetStartedNavigationURLS());
|
| +
|
| + std::vector<GURL> finished_navigation = {kUrl};
|
| + EXPECT_EQ(finished_navigation, logger.GetFinishedNavigationURLS());
|
| +}
|
| +
|
| } // namespace content
|
|
|