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

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

Issue 2957783002: Fix wrong ui::PAGE_TRANSITION_FORWARD_BACK in tests. (Closed)
Patch Set: Created 3 years, 5 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 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't 1258 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't
1259 // happen, but we have seen it when going back quickly across many entries 1259 // happen, but we have seen it when going back quickly across many entries
1260 // (http://crbug.com/93427). 1260 // (http://crbug.com/93427).
1261 contents()->GetController().GoBack(); 1261 contents()->GetController().GoBack();
1262 EXPECT_TRUE(rfh2->is_waiting_for_beforeunload_ack()); 1262 EXPECT_TRUE(rfh2->is_waiting_for_beforeunload_ack());
1263 contents()->GetMainFrame()->PrepareForCommit(); 1263 contents()->GetMainFrame()->PrepareForCommit();
1264 EXPECT_FALSE(rfh2->is_waiting_for_beforeunload_ack()); 1264 EXPECT_FALSE(rfh2->is_waiting_for_beforeunload_ack());
1265 1265
1266 // The back navigation commits. 1266 // The back navigation commits.
1267 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); 1267 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
1268 contents()->GetPendingMainFrame()->SendNavigate( 1268 contents()->GetPendingMainFrame()->SendNavigateWithTransition(
1269 entry1->GetUniqueID(), false, entry1->GetURL()); 1269 entry1->GetUniqueID(), false, entry1->GetURL(),
1270 entry1->GetTransitionType());
1270 EXPECT_TRUE(rfh2->IsWaitingForUnloadACK()); 1271 EXPECT_TRUE(rfh2->IsWaitingForUnloadACK());
1271 EXPECT_FALSE(rfh2->is_active()); 1272 EXPECT_FALSE(rfh2->is_active());
1272 1273
1273 // We should be able to navigate forward. 1274 // We should be able to navigate forward.
1274 contents()->GetController().GoForward(); 1275 contents()->GetController().GoForward();
1275 contents()->GetMainFrame()->PrepareForCommit(); 1276 contents()->GetMainFrame()->PrepareForCommit();
1276 const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry(); 1277 const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry();
1277 contents()->GetPendingMainFrame()->SendNavigate( 1278 contents()->GetPendingMainFrame()->SendNavigateWithTransition(
1278 entry2->GetUniqueID(), false, entry2->GetURL()); 1279 entry2->GetUniqueID(), false, entry2->GetURL(),
1280 entry2->GetTransitionType());
1279 EXPECT_TRUE(main_test_rfh()->is_active()); 1281 EXPECT_TRUE(main_test_rfh()->is_active());
1280 } 1282 }
1281 1283
1282 // Test that we create swapped out RFHs for the opener chain when navigating an 1284 // Test that we create swapped out RFHs for the opener chain when navigating an
1283 // opened tab cross-process. This allows us to support certain cross-process 1285 // opened tab cross-process. This allows us to support certain cross-process
1284 // JavaScript calls (http://crbug.com/99202). 1286 // JavaScript calls (http://crbug.com/99202).
1285 TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) { 1287 TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) {
1286 const GURL kUrl1("http://www.google.com/"); 1288 const GURL kUrl1("http://www.google.com/");
1287 const GURL kUrl2("http://www.chromium.org/"); 1289 const GURL kUrl2("http://www.chromium.org/");
1288 const GURL kChromeUrl("chrome://foo"); 1290 const GURL kChromeUrl("chrome://foo");
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 contents()->GetMainFrame()->PrepareForCommit(); 1435 contents()->GetMainFrame()->PrepareForCommit();
1434 1436
1435 // Disown the opener from rfh2. 1437 // Disown the opener from rfh2.
1436 rfh2->DidChangeOpener(MSG_ROUTING_NONE); 1438 rfh2->DidChangeOpener(MSG_ROUTING_NONE);
1437 1439
1438 // Ensure the opener is cleared. 1440 // Ensure the opener is cleared.
1439 EXPECT_FALSE(contents()->HasOpener()); 1441 EXPECT_FALSE(contents()->HasOpener());
1440 1442
1441 // The back navigation commits. 1443 // The back navigation commits.
1442 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); 1444 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
1443 contents()->GetPendingMainFrame()->SendNavigate( 1445 contents()->GetPendingMainFrame()->SendNavigateWithTransition(
1444 entry1->GetUniqueID(), false, entry1->GetURL()); 1446 entry1->GetUniqueID(), false, entry1->GetURL(),
1447 entry1->GetTransitionType());
1445 1448
1446 // Ensure the opener is still cleared. 1449 // Ensure the opener is still cleared.
1447 EXPECT_FALSE(contents()->HasOpener()); 1450 EXPECT_FALSE(contents()->HasOpener());
1448 } 1451 }
1449 1452
1450 // Test that a page can disown the opener just after a cross-process navigation 1453 // Test that a page can disown the opener just after a cross-process navigation
1451 // commits. 1454 // commits.
1452 TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) { 1455 TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) {
1453 const GURL kUrl1("http://www.google.com/"); 1456 const GURL kUrl1("http://www.google.com/");
1454 const GURL kUrl2("http://www.chromium.org/"); 1457 const GURL kUrl2("http://www.chromium.org/");
(...skipping 12 matching lines...) Expand all
1467 // Navigate to a cross-site URL (different SiteInstance but same 1470 // Navigate to a cross-site URL (different SiteInstance but same
1468 // BrowsingInstance). 1471 // BrowsingInstance).
1469 contents()->NavigateAndCommit(kUrl2); 1472 contents()->NavigateAndCommit(kUrl2);
1470 TestRenderFrameHost* rfh2 = main_test_rfh(); 1473 TestRenderFrameHost* rfh2 = main_test_rfh();
1471 EXPECT_NE(site_instance1, rfh2->GetSiteInstance()); 1474 EXPECT_NE(site_instance1, rfh2->GetSiteInstance());
1472 1475
1473 // Commit a back navigation before the DidChangeOpener message arrives. 1476 // Commit a back navigation before the DidChangeOpener message arrives.
1474 contents()->GetController().GoBack(); 1477 contents()->GetController().GoBack();
1475 contents()->GetMainFrame()->PrepareForCommit(); 1478 contents()->GetMainFrame()->PrepareForCommit();
1476 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); 1479 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
1477 contents()->GetPendingMainFrame()->SendNavigate( 1480 contents()->GetPendingMainFrame()->SendNavigateWithTransition(
1478 entry1->GetUniqueID(), false, entry1->GetURL()); 1481 entry1->GetUniqueID(), false, entry1->GetURL(),
1482 entry1->GetTransitionType());
1479 1483
1480 // Disown the opener from rfh2. 1484 // Disown the opener from rfh2.
1481 rfh2->DidChangeOpener(MSG_ROUTING_NONE); 1485 rfh2->DidChangeOpener(MSG_ROUTING_NONE);
1482 EXPECT_FALSE(contents()->HasOpener()); 1486 EXPECT_FALSE(contents()->HasOpener());
1483 } 1487 }
1484 1488
1485 // Test that we clean up swapped out RenderViewHosts when a process hosting 1489 // Test that we clean up swapped out RenderViewHosts when a process hosting
1486 // those associated RenderViews crashes. http://crbug.com/258993 1490 // those associated RenderViews crashes. http://crbug.com/258993
1487 TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) { 1491 TEST_F(RenderFrameHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) {
1488 const GURL kUrl1("http://www.google.com/"); 1492 const GURL kUrl1("http://www.google.com/");
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after
3156 ASSERT_FALSE(delete_observer.deleted()); 3160 ASSERT_FALSE(delete_observer.deleted());
3157 EXPECT_FALSE(initial_rfh->is_active()); 3161 EXPECT_FALSE(initial_rfh->is_active());
3158 3162
3159 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not 3163 // The initial RFH receives a DidStartProvisionalLoad IPC. It should not
3160 // create a NavigationHandle. 3164 // create a NavigationHandle.
3161 initial_rfh->SimulateNavigationStart(kUrl3); 3165 initial_rfh->SimulateNavigationStart(kUrl3);
3162 EXPECT_FALSE(initial_rfh->navigation_handle()); 3166 EXPECT_FALSE(initial_rfh->navigation_handle());
3163 } 3167 }
3164 3168
3165 } // namespace content 3169 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698