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 4594946033b61ab03c8ae56ce52954927d83dd72..9b939abc0ead58a07a18483b424d5d53bd138c48 100644 |
| --- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| +++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc |
| @@ -57,6 +57,27 @@ static std::string kRemoveFrameScript = |
| "var f = document.querySelector('iframe');" |
| "f.parentNode.removeChild(f);"; |
| +class RenderProcessGoneObserver : public content::WebContentsObserver { |
|
Charlie Reis
2016/08/10 17:03:09
Can we use RenderProcessHostWatcher from browser_t
nasko
2016/08/10 18:08:51
I tried to find it, but couldn't, so put this one
|
| + public: |
| + RenderProcessGoneObserver(content::WebContents* web_contents) |
| + : content::WebContentsObserver(web_contents), |
| + status_(base::TerminationStatus::TERMINATION_STATUS_MAX_ENUM) {} |
| + ~RenderProcessGoneObserver() override {} |
| + |
| + void RenderProcessGone(base::TerminationStatus status) override { |
| + status_ = status; |
| + } |
| + |
| + base::TerminationStatus status() { return status_; } |
| + |
| + bool is_gone() { |
| + return status_ != base::TerminationStatus::TERMINATION_STATUS_MAX_ENUM; |
| + } |
| + |
| + private: |
| + base::TerminationStatus status_; |
| +}; |
| + |
| } // namespace |
| namespace content { |
| @@ -5616,4 +5637,56 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| EXPECT_EQ(0U, root->child_count()); |
| } |
| +// Test that navigations classified as SAME_PAGE properly update all the |
| +// members of FrameNavigationEntry. If not, it is possible to get mismatch |
|
Charlie Reis
2016/08/10 17:03:09
nit: a mismatch
nasko
2016/08/10 18:08:51
Done.
|
| +// between the origin and URL of a document as seen in |
| +// https://crbug.com/630103. |
| +IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| + EnsureSamePageNavigationUpdatesFrameNavigationEntry) { |
| + WebContentsImpl* web_contents = |
| + static_cast<WebContentsImpl*>(shell()->web_contents()); |
| + FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
| + |
| + // Navigate to a simple page and then perform an in-page navigation. |
| + GURL start_url(embedded_test_server()->GetURL("/title1.html")); |
| + EXPECT_TRUE(NavigateToURL(shell(), start_url)); |
| + |
| + GURL same_page_url(embedded_test_server()->GetURL("/title1.html#foo")); |
| + EXPECT_TRUE(NavigateToURL(shell(), same_page_url)); |
| + EXPECT_EQ(2, web_contents->GetController().GetEntryCount()); |
| + |
| + // Replace the URL of the current NavigationEntry with one that will cause |
| + // a server redirect when loaded. |
| + { |
| + GURL redirect_dest_url( |
| + embedded_test_server()->GetURL("b.com", "/simple1.html")); |
| + TestNavigationObserver observer(web_contents); |
| + std::string script = "history.replaceState({}, '', '/server-redirect?" + |
| + redirect_dest_url.spec() + "')"; |
| + EXPECT_TRUE(ExecuteScript(root, script)); |
| + observer.Wait(); |
| + } |
| + |
| + // Simulate the user hitting Enter in the omnibox without changing the URL. |
| + { |
| + TestNavigationObserver observer(web_contents); |
| + web_contents->GetController().LoadURL(web_contents->GetLastCommittedURL(), |
| + Referrer(), ui::PAGE_TRANSITION_LINK, |
| + std::string()); |
| + observer.Wait(); |
| + } |
| + |
| + // The renderer process has a CHECK to ensure there are no mismatches between |
| + // origin and URL, so going back in history should succeed without a process |
| + // crash. |
| + RenderProcessGoneObserver process_observer(web_contents); |
| + { |
| + TestNavigationObserver observer(web_contents); |
| + web_contents->GetController().GoBack(); |
| + observer.Wait(); |
| + } |
| + EXPECT_TRUE(!process_observer.is_gone()) << "Exit status: " |
|
Charlie Reis
2016/08/10 17:03:09
Hmm. It would be nice to verify this beyond avoid
nasko
2016/08/10 18:08:51
I've made it use suborigins on the same site, so w
Charlie Reis
2016/08/10 18:36:16
Thanks for adding the origin check-- that helps.
nasko
2016/08/10 19:42:52
Done.
|
| + << process_observer.status(); |
| +} |
| + |
| } // namespace content |