Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 2783723002: Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: fix content_browsertests with plznavigate and also remove now unnecessary unloadcontroller change Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <tuple> 9 #include <tuple>
10 #include <utility> 10 #include <utility>
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 rfh1->GetSiteInstance()->IncrementActiveFrameCount(); 1257 rfh1->GetSiteInstance()->IncrementActiveFrameCount();
1258 1258
1259 contents()->NavigateAndCommit(kUrl2); 1259 contents()->NavigateAndCommit(kUrl2);
1260 TestRenderFrameHost* rfh2 = main_test_rfh(); 1260 TestRenderFrameHost* rfh2 = main_test_rfh();
1261 rfh2->GetSiteInstance()->IncrementActiveFrameCount(); 1261 rfh2->GetSiteInstance()->IncrementActiveFrameCount();
1262 1262
1263 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't 1263 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't
1264 // happen, but we have seen it when going back quickly across many entries 1264 // happen, but we have seen it when going back quickly across many entries
1265 // (http://crbug.com/93427). 1265 // (http://crbug.com/93427).
1266 contents()->GetController().GoBack(); 1266 contents()->GetController().GoBack();
1267 EXPECT_TRUE(rfh2->is_waiting_for_beforeunload_ack());
nasko 2017/03/29 23:31:26 Why not set_has_beforeunload_handlers on rfh2? We
jam 2017/03/30 14:53:22 similar to my other reply, this isn't what the uni
1268 contents()->GetMainFrame()->PrepareForCommit(); 1267 contents()->GetMainFrame()->PrepareForCommit();
1269 EXPECT_FALSE(rfh2->is_waiting_for_beforeunload_ack());
1270 1268
1271 // The back navigation commits. 1269 // The back navigation commits.
1272 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); 1270 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
1273 contents()->GetPendingMainFrame()->SendNavigate( 1271 contents()->GetPendingMainFrame()->SendNavigate(
1274 entry1->GetUniqueID(), false, entry1->GetURL()); 1272 entry1->GetUniqueID(), false, entry1->GetURL());
1275 EXPECT_TRUE(rfh2->IsWaitingForUnloadACK()); 1273 EXPECT_TRUE(rfh2->IsWaitingForUnloadACK());
1276 EXPECT_FALSE(rfh2->is_active()); 1274 EXPECT_FALSE(rfh2->is_active());
1277 1275
1278 // We should be able to navigate forward. 1276 // We should be able to navigate forward.
1279 contents()->GetController().GoForward(); 1277 contents()->GetController().GoForward();
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 CancelPendingProperlyDeletesOrSwaps) { 1875 CancelPendingProperlyDeletesOrSwaps) {
1878 const GURL kUrl1("http://www.google.com/"); 1876 const GURL kUrl1("http://www.google.com/");
1879 const GURL kUrl2("http://www.chromium.org/"); 1877 const GURL kUrl2("http://www.chromium.org/");
1880 RenderFrameHostImpl* pending_rfh = NULL; 1878 RenderFrameHostImpl* pending_rfh = NULL;
1881 base::TimeTicks now = base::TimeTicks::Now(); 1879 base::TimeTicks now = base::TimeTicks::Now();
1882 1880
1883 // Navigate to the first page. 1881 // Navigate to the first page.
1884 contents()->NavigateAndCommit(kUrl1); 1882 contents()->NavigateAndCommit(kUrl1);
1885 TestRenderFrameHost* rfh1 = main_test_rfh(); 1883 TestRenderFrameHost* rfh1 = main_test_rfh();
1886 EXPECT_TRUE(rfh1->is_active()); 1884 EXPECT_TRUE(rfh1->is_active());
1885 rfh1->set_has_beforeunload_handlers();
1887 1886
1888 // Navigate to a new site, starting a cross-site navigation. 1887 // Navigate to a new site, starting a cross-site navigation.
1889 controller().LoadURL( 1888 controller().LoadURL(
1890 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); 1889 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
1891 { 1890 {
1892 pending_rfh = contents()->GetPendingMainFrame(); 1891 pending_rfh = contents()->GetPendingMainFrame();
1893 RenderFrameDeletedObserver rfh_deleted_observer(pending_rfh); 1892 RenderFrameDeletedObserver rfh_deleted_observer(pending_rfh);
1894 1893
1895 // Cancel the navigation by simulating a declined beforeunload dialog. 1894 // Cancel the navigation by simulating a declined beforeunload dialog.
1896 contents()->GetMainFrame()->OnMessageReceived( 1895 contents()->GetMainFrame()->OnMessageReceived(
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
3152 ASSERT_FALSE(delete_observer.deleted()); 3151 ASSERT_FALSE(delete_observer.deleted());
3153 EXPECT_FALSE(initial_rfh->is_active()); 3152 EXPECT_FALSE(initial_rfh->is_active());
3154 3153
3155 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not 3154 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not
3156 // create a NavigationHandle. 3155 // create a NavigationHandle.
3157 initial_rfh->SimulateNavigationStart(kUrl3); 3156 initial_rfh->SimulateNavigationStart(kUrl3);
3158 EXPECT_FALSE(initial_rfh->navigation_handle()); 3157 EXPECT_FALSE(initial_rfh->navigation_handle());
3159 } 3158 }
3160 3159
3161 } // namespace content 3160 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698