| Index: content/browser/web_contents/web_contents_impl_unittest.cc
|
| diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
|
| index b45c161edfc8dc43b2ec03b05f9689dd8511d3a3..5a358dc809e6e4052507946be5d579bab7cd3796 100644
|
| --- a/content/browser/web_contents/web_contents_impl_unittest.cc
|
| +++ b/content/browser/web_contents/web_contents_impl_unittest.cc
|
| @@ -2,6 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/command_line.h"
|
| #include "base/logging.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "content/browser/frame_host/cross_site_transferring_request.h"
|
| @@ -25,6 +26,7 @@
|
| #include "content/public/browser/web_ui_controller.h"
|
| #include "content/public/common/bindings_policy.h"
|
| #include "content/public/common/content_constants.h"
|
| +#include "content/public/common/content_switches.h"
|
| #include "content/public/common/url_constants.h"
|
| #include "content/public/common/url_utils.h"
|
| #include "content/public/test/mock_render_process_host.h"
|
| @@ -476,6 +478,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + orig_rfh->PrepareForCommit(url);
|
| contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
|
|
| // Keep the number of active frames in orig_rfh's SiteInstance non-zero so
|
| @@ -491,6 +494,10 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
|
| const GURL url2("http://www.yahoo.com");
|
| controller().LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation)) {
|
| + orig_rfh->PrepareForCommit(url2);
|
| + }
|
| EXPECT_TRUE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(url, contents()->GetLastCommittedURL());
|
| EXPECT_EQ(url2, contents()->GetVisibleURL());
|
| @@ -500,9 +507,12 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
|
| &pending_rvh_delete_count);
|
|
|
| // Navigations should be suspended in pending_rfh until BeforeUnloadACK.
|
| - EXPECT_TRUE(pending_rfh->are_navigations_suspended());
|
| - orig_rfh->SendBeforeUnloadACK(true);
|
| - EXPECT_FALSE(pending_rfh->are_navigations_suspended());
|
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation)) {
|
| + EXPECT_TRUE(pending_rfh->are_navigations_suspended());
|
| + orig_rfh->SendBeforeUnloadACK(true);
|
| + EXPECT_FALSE(pending_rfh->are_navigations_suspended());
|
| + }
|
|
|
| // DidNavigate from the pending page
|
| contents()->TestDidNavigate(
|
| @@ -529,14 +539,21 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) {
|
| // stored in the NavigationEntry, so it should be the same as at the start.
|
| // We should use the same RFH as before, swapping it back in.
|
| controller().GoBack();
|
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation)) {
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| + }
|
| TestRenderFrameHost* goback_rfh = contents()->GetPendingMainFrame();
|
| EXPECT_EQ(orig_rfh, goback_rfh);
|
| EXPECT_TRUE(contents()->cross_navigation_pending());
|
|
|
| // Navigations should be suspended in goback_rfh until BeforeUnloadACK.
|
| - EXPECT_TRUE(goback_rfh->are_navigations_suspended());
|
| - pending_rfh->SendBeforeUnloadACK(true);
|
| - EXPECT_FALSE(goback_rfh->are_navigations_suspended());
|
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation)) {
|
| + EXPECT_TRUE(goback_rfh->are_navigations_suspended());
|
| + pending_rfh->SendBeforeUnloadACK(true);
|
| + EXPECT_FALSE(goback_rfh->are_navigations_suspended());
|
| + }
|
|
|
| // DidNavigate from the back action
|
| contents()->TestDidNavigate(goback_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED);
|
| @@ -568,6 +585,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
|
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| @@ -581,6 +599,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) {
|
| const GURL url2("http://www.yahoo.com");
|
| controller().LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url2);
|
| TestRenderFrameHost* new_rfh = contents()->GetMainFrame();
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL);
|
| @@ -612,6 +631,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
|
|
| // Open a new contents with the same SiteInstance, navigated to the same site.
|
| @@ -620,6 +640,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
|
| contents2->GetController().LoadURL(url, Referrer(),
|
| ui::PAGE_TRANSITION_TYPED,
|
| std::string());
|
| + contents2->GetMainFrame()->PrepareForCommit(url);
|
| // Need this page id to be 2 since the site instance is the same (which is the
|
| // scope of page IDs) and we want to consider this a new page.
|
| contents2->TestDidNavigate(
|
| @@ -629,7 +650,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
|
| const GURL url2a("http://www.yahoo.com");
|
| controller().LoadURL(
|
| url2a, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| - orig_rfh->SendBeforeUnloadACK(true);
|
| + orig_rfh->PrepareForCommit(url2a);
|
| TestRenderFrameHost* pending_rfh_a = contents()->GetPendingMainFrame();
|
| contents()->TestDidNavigate(
|
| pending_rfh_a, 1, url2a, ui::PAGE_TRANSITION_TYPED);
|
| @@ -642,7 +663,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) {
|
| ui::PAGE_TRANSITION_TYPED,
|
| std::string());
|
| TestRenderFrameHost* rfh2 = contents2->GetMainFrame();
|
| - rfh2->SendBeforeUnloadACK(true);
|
| + rfh2->PrepareForCommit(url2b);
|
| TestRenderFrameHost* pending_rfh_b = contents2->GetPendingMainFrame();
|
| EXPECT_TRUE(pending_rfh_b != NULL);
|
| EXPECT_TRUE(contents2->cross_navigation_pending());
|
| @@ -677,6 +698,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
|
| const GURL native_url("non-site-url://stuffandthings");
|
| controller().LoadURL(
|
| native_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(native_url);
|
| contents()->TestDidNavigate(
|
| orig_rfh, 1, native_url, ui::PAGE_TRANSITION_TYPED);
|
|
|
| @@ -693,6 +715,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(native_url, contents()->GetLastCommittedURL());
|
| EXPECT_EQ(url, contents()->GetVisibleURL());
|
| @@ -713,6 +736,10 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
|
| const GURL url2("http://www.yahoo.com");
|
| controller().LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation)) {
|
| + orig_rfh->PrepareForCommit(url2);
|
| + }
|
| EXPECT_TRUE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(url, contents()->GetLastCommittedURL());
|
| EXPECT_EQ(url2, contents()->GetVisibleURL());
|
| @@ -722,9 +749,12 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) {
|
| &pending_rvh_delete_count);
|
|
|
| // Navigations should be suspended in pending_rvh until BeforeUnloadACK.
|
| - EXPECT_TRUE(pending_rfh->are_navigations_suspended());
|
| - orig_rfh->SendBeforeUnloadACK(true);
|
| - EXPECT_FALSE(pending_rfh->are_navigations_suspended());
|
| + if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation)) {
|
| + EXPECT_TRUE(pending_rfh->are_navigations_suspended());
|
| + orig_rfh->SendBeforeUnloadACK(true);
|
| + EXPECT_FALSE(pending_rfh->are_navigations_suspended());
|
| + }
|
|
|
| // DidNavigate from the pending page.
|
| contents()->TestDidNavigate(
|
| @@ -818,6 +848,7 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) {
|
| ASSERT_EQ(0u, entries.size());
|
| ASSERT_EQ(1, controller().GetEntryCount());
|
| controller().GoToIndex(0);
|
| + orig_rfh->PrepareForCommit(regular_url);
|
| contents()->TestDidNavigate(
|
| orig_rfh, 0, regular_url, ui::PAGE_TRANSITION_RELOAD);
|
| EXPECT_EQ(orig_instance, contents()->GetSiteInstance());
|
| @@ -827,6 +858,7 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + orig_rfh->PrepareForCommit(url);
|
| contents()->TestDidNavigate(
|
| contents()->GetPendingMainFrame(), 2, url, ui::PAGE_TRANSITION_TYPED);
|
| EXPECT_NE(orig_instance, contents()->GetSiteInstance());
|
| @@ -844,13 +876,14 @@ TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + orig_rfh->PrepareForCommit(url);
|
| contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
|
|
| // Start to navigate first tab to a new site, so that it has a pending RVH.
|
| const GURL url2("http://www.yahoo.com");
|
| controller().LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| - orig_rfh->SendBeforeUnloadACK(true);
|
| + orig_rfh->PrepareForCommit(url2);
|
| TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame();
|
|
|
| // While it is still pending, simulate opening a new tab with the first tab
|
| @@ -874,6 +907,7 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| contents()->TestDidNavigate(
|
| orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
|
|
| @@ -884,6 +918,7 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
|
| contents2->GetController().LoadURL(url2, Referrer(),
|
| ui::PAGE_TRANSITION_TYPED,
|
| std::string());
|
| + contents2->GetMainFrame()->PrepareForCommit(url2);
|
| // The first RVH in contents2 isn't live yet, so we shortcut the cross site
|
| // pending.
|
| TestRenderFrameHost* rfh2 = contents2->GetMainFrame();
|
| @@ -907,6 +942,7 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) {
|
| controller().LoadURL(
|
| url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| + contents()->GetMainFrame()->PrepareForCommit(url3);
|
| contents()->TestDidNavigate(
|
| orig_rfh, 3, url3, ui::PAGE_TRANSITION_TYPED);
|
| SiteInstance* instance4 = contents()->GetSiteInstance();
|
| @@ -923,6 +959,7 @@ TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
|
| @@ -931,22 +968,21 @@ TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) {
|
| const GURL url2("http://www.yahoo.com");
|
| controller().LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| - EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
| base::TimeTicks now = base::TimeTicks::Now();
|
| orig_rfh->OnMessageReceived(
|
| FrameHostMsg_BeforeUnload_ACK(0, false, now, now));
|
| - EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
|
|
|
| // Navigate again, but simulate an onbeforeunload approval.
|
| controller().LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| - EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
| now = base::TimeTicks::Now();
|
| - orig_rfh->OnMessageReceived(
|
| - FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
|
| - EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + orig_rfh->PrepareForCommit(url2);
|
| + EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
| EXPECT_TRUE(contents()->cross_navigation_pending());
|
| TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame();
|
|
|
| @@ -973,6 +1009,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
|
| @@ -981,16 +1018,15 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) {
|
| const GURL url2("http://www.yahoo.com");
|
| controller().LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| - EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| - base::TimeTicks now = base::TimeTicks::Now();
|
| - orig_rfh->OnMessageReceived(FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
|
| + EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
| + orig_rfh->PrepareForCommit(url2);
|
| EXPECT_TRUE(contents()->cross_navigation_pending());
|
|
|
| // Suppose the original renderer navigates before the new one is ready.
|
| orig_rfh->SendNavigate(2, GURL("http://www.google.com/foo"));
|
|
|
| // Verify that the pending navigation is cancelled.
|
| - EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
| SiteInstance* instance2 = contents()->GetSiteInstance();
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
|
| @@ -1004,6 +1040,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
|
| controller().LoadURL(
|
| url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| TestRenderFrameHost* ntp_rfh = contents()->GetMainFrame();
|
| + ntp_rfh->PrepareForCommit(url1);
|
| contents()->TestDidNavigate(ntp_rfh, 1, url1, ui::PAGE_TRANSITION_TYPED);
|
| NavigationEntry* entry1 = controller().GetLastCommittedEntry();
|
| SiteInstance* instance1 = contents()->GetSiteInstance();
|
| @@ -1024,10 +1061,9 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
|
| TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame();
|
|
|
| // Simulate beforeunload approval.
|
| - EXPECT_TRUE(ntp_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_TRUE(ntp_rfh->IsWaitingForBeforeUnloadACK());
|
| base::TimeTicks now = base::TimeTicks::Now();
|
| - ntp_rfh->OnMessageReceived(
|
| - FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
|
| + ntp_rfh->PrepareForCommit(url2);
|
|
|
| // DidNavigate from the pending page.
|
| contents()->TestDidNavigate(
|
| @@ -1050,6 +1086,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
|
| controller().LoadURL(
|
| url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| + contents()->GetMainFrame()->PrepareForCommit(url3);
|
| contents()->TestDidNavigate(
|
| google_rfh, 2, url3, ui::PAGE_TRANSITION_TYPED);
|
| NavigationEntry* entry3 = controller().GetLastCommittedEntry();
|
| @@ -1075,8 +1112,9 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) {
|
| EXPECT_EQ(entry1, controller().GetPendingEntry());
|
|
|
| // Simulate beforeunload approval.
|
| - EXPECT_TRUE(google_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_TRUE(google_rfh->IsWaitingForBeforeUnloadACK());
|
| now = base::TimeTicks::Now();
|
| + google_rfh->PrepareForCommit(url2);
|
| google_rfh->OnMessageReceived(
|
| FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
|
|
|
| @@ -1108,6 +1146,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
|
| @@ -1122,14 +1161,12 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) {
|
| TestRenderFrameHost* child_rfh = orig_rfh->AppendChild("subframe");
|
| child_rfh->SendNavigateWithTransition(
|
| 1, GURL("http://google.com/frame"), ui::PAGE_TRANSITION_AUTO_SUBFRAME);
|
| - EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
|
|
| // Now simulate the onbeforeunload approval and verify the navigation is
|
| // not canceled.
|
| - base::TimeTicks now = base::TimeTicks::Now();
|
| - orig_rfh->OnMessageReceived(
|
| - FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
|
| - EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + orig_rfh->PrepareForCommit(url2);
|
| + EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
| EXPECT_TRUE(contents()->cross_navigation_pending());
|
| }
|
|
|
| @@ -1151,7 +1188,7 @@ TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) {
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame();
|
| EXPECT_TRUE(contents()->cross_navigation_pending());
|
| - EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
|
|
| // Suppose the first navigation tries to commit now, with a
|
| // FrameMsg_Stop in flight. This should not cancel the pending navigation,
|
| @@ -1159,7 +1196,7 @@ TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) {
|
| orig_rfh->SendNavigate(1, GURL("chrome://blah"));
|
| EXPECT_TRUE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
|
| - EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
|
|
| // The pending navigation should be able to commit successfully.
|
| contents()->TestDidNavigate(pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED);
|
| @@ -1177,6 +1214,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationCanceled) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
|
| @@ -1185,10 +1223,8 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationCanceled) {
|
| const GURL url2("http://www.yahoo.com");
|
| controller().LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| - EXPECT_TRUE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| - base::TimeTicks now = base::TimeTicks::Now();
|
| - orig_rfh->OnMessageReceived(
|
| - FrameHostMsg_BeforeUnload_ACK(0, true, now, now));
|
| + EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
| + contents()->GetMainFrame()->PrepareForCommit(url2);
|
| EXPECT_TRUE(contents()->cross_navigation_pending());
|
|
|
| // Simulate swap out message when the response arrives.
|
| @@ -1201,7 +1237,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationCanceled) {
|
|
|
| // Verify that the pending navigation is cancelled and the renderer is no
|
| // longer swapped out.
|
| - EXPECT_FALSE(orig_rfh->is_waiting_for_beforeunload_ack());
|
| + EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK());
|
| SiteInstance* instance2 = contents()->GetSiteInstance();
|
| EXPECT_FALSE(contents()->cross_navigation_pending());
|
| EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
|
| @@ -1293,6 +1329,7 @@ TEST_F(WebContentsImplTest, NavigationExitsFullscreen) {
|
| const GURL url("http://www.google.com");
|
| controller().LoadURL(
|
| url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url);
|
| contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
|
| EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
|
|
|
| @@ -1310,6 +1347,7 @@ TEST_F(WebContentsImplTest, NavigationExitsFullscreen) {
|
| const GURL url2("http://www.yahoo.com");
|
| controller().LoadURL(
|
| url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
|
| + contents()->GetMainFrame()->PrepareForCommit(url2);
|
| TestRenderFrameHost* const pending_rfh = contents()->GetPendingMainFrame();
|
| contents()->TestDidNavigate(
|
| pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED);
|
| @@ -2637,10 +2675,12 @@ TEST_F(WebContentsImplTest, ActiveContentsCountNavigate) {
|
| EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount());
|
|
|
| // Navigate to a URL in a different site.
|
| - contents->GetController().LoadURL(GURL("http://b.com"),
|
| + const GURL kUrl = GURL("http://b.com");
|
| + contents->GetController().LoadURL(kUrl,
|
| Referrer(),
|
| ui::PAGE_TRANSITION_TYPED,
|
| std::string());
|
| + contents->GetMainFrame()->PrepareForCommit(kUrl);
|
| EXPECT_TRUE(contents->cross_navigation_pending());
|
| EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount());
|
| contents->CommitPendingNavigation();
|
| @@ -2671,6 +2711,7 @@ TEST_F(WebContentsImplTest, ActiveContentsCountChangeBrowsingInstance) {
|
| Referrer(),
|
| ui::PAGE_TRANSITION_TYPED,
|
| std::string());
|
| + contents->GetMainFrame()->PrepareForCommit(GURL(kTestWebUIUrl));
|
| EXPECT_TRUE(contents->cross_navigation_pending());
|
| scoped_refptr<SiteInstance> instance_webui(
|
| contents->GetPendingMainFrame()->GetSiteInstance());
|
|
|