Chromium Code Reviews| Index: content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| index ba4a49d1d4de3f05005e651f220a64d46afd8550..50f64afd8610f75e661d78c4e7abcab5621c72e7 100644 |
| --- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| +++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| @@ -5,6 +5,7 @@ |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| #include "base/strings/stringprintf.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "content/browser/frame_host/frame_navigation_entry.h" |
| #include "content/browser/frame_host/frame_tree.h" |
| #include "content/browser/frame_host/navigation_controller_impl.h" |
| @@ -2130,4 +2131,64 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
| } |
| +namespace { |
| + |
| +class RenderProcessKilledObserver : public WebContentsObserver { |
| + public: |
| + RenderProcessKilledObserver(WebContents* web_contents) |
| + : WebContentsObserver(web_contents) {} |
| + ~RenderProcessKilledObserver() override {} |
| + |
| + void RenderProcessGone(base::TerminationStatus status) override { |
| + CHECK_NE(status, |
| + base::TerminationStatus::TERMINATION_STATUS_PROCESS_WAS_KILLED); |
| + } |
| +}; |
| + |
| +} |
| + |
| +// This tests for a race in ReloadOriginalRequest. Not crashing means that the |
| +// test is successful. |
| +IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ReloadOriginalRequest) { |
| + GURL url(embedded_test_server()->GetURL( |
| + "/navigation_controller/simple_page_1.html")); |
| + NavigateToURL(shell(), url); |
| + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| + ->GetFrameTree() |
| + ->root(); |
| + RenderProcessKilledObserver kill_observer(shell()->web_contents()); |
| + |
| + // Redirect. |
| + { |
| + GURL foo_url(embedded_test_server()->GetURL( |
| + "foo.com", "/navigation_controller/simple_page_1.html")); |
| + std::string script = "location.replace('" + foo_url.spec() + "');"; |
| + FrameNavigateParamsCapturer capturer(root); |
| + EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); |
| + capturer.Wait(); |
| + EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| + capturer.params().transition); |
| + EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
| + } |
| + |
| + // Modify an entry in the session history and reload the original request. |
| + { |
| + std::string script = "history.replaceState({}, '', 'foo');"; |
| + root->render_manager() |
| + ->current_frame_host() |
| + ->ExecuteJavaScriptWithUserGestureForTests(base::UTF8ToUTF16(script)); |
|
Charlie Reis
2015/07/08 23:23:37
Please add a comment saying why this has to be don
lfg
2015/07/14 18:58:31
Done.
|
| + EXPECT_FALSE(shell()->web_contents()->IsLoading()); |
| + shell()->web_contents()->GetController().ReloadOriginalRequestURL(false); |
| + EXPECT_TRUE(shell()->web_contents()->IsLoading()); |
| + |
| + // Wait until there's no more navigations. |
| + while (shell()->web_contents()->GetLastCommittedURL() != url) |
|
Charlie Reis
2015/07/08 23:23:37
Does replaceState generate a load stop? I'm wonde
lfg
2015/07/14 18:58:31
It only generates a load stop when IsLoading() is
|
| + RunAllPendingInMessageLoop(); |
| + |
| + // Make sure the renderer is still alive. |
| + EXPECT_TRUE( |
| + ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
| + } |
| +} |
| + |
| } // namespace content |