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

Side by Side Diff: content/browser/cross_site_transfer_browsertest.cc

Issue 1777903003: Ensure the NavigationHandle's nav entry ID is updated during transfers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move fix to another CL (now cleanup only) Created 4 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "content/browser/loader/resource_dispatcher_host_impl.h" 8 #include "content/browser/loader/resource_dispatcher_host_impl.h"
9 #include "content/public/browser/navigation_entry.h" 9 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/browser/resource_dispatcher_host_delegate.h" 10 #include "content/public/browser/resource_dispatcher_host_delegate.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 // Make sure the request succeeded. 287 // Make sure the request succeeded.
288 EXPECT_TRUE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); 288 EXPECT_TRUE(tracking_delegate().WaitForTrackedURLAndGetCompleted());
289 } 289 }
290 290
291 // Tests that the |should_replace_current_entry| flag persists correctly across 291 // Tests that the |should_replace_current_entry| flag persists correctly across
292 // request transfers that began with a content-initiated in-process 292 // request transfers that began with a content-initiated in-process
293 // navigation. This test is the same as the test above, except transfering from 293 // navigation. This test is the same as the test above, except transfering from
294 // in-process. 294 // in-process.
295 IN_PROC_BROWSER_TEST_F(CrossSiteTransferTest, 295 IN_PROC_BROWSER_TEST_F(CrossSiteTransferTest,
296 ReplaceEntryInProcessThenTranfers) { 296 ReplaceEntryInProcessThenTransfer) {
297 const NavigationController& controller = 297 const NavigationController& controller =
298 shell()->web_contents()->GetController(); 298 shell()->web_contents()->GetController();
299 299
300 // Navigate to a starting URL, so there is a history entry to replace. 300 // Navigate to a starting URL, so there is a history entry to replace.
301 GURL url = embedded_test_server()->GetURL("/site_isolation/blank.html?1"); 301 GURL url = embedded_test_server()->GetURL("/site_isolation/blank.html?1");
302 EXPECT_TRUE(NavigateToURL(shell(), url)); 302 EXPECT_TRUE(NavigateToURL(shell(), url));
303 303
304 // Force all future navigations to transfer. Note that this includes same-site 304 // Force all future navigations to transfer. Note that this includes same-site
305 // navigiations which may cause double process swaps (via OpenURL and then via 305 // navigiations which may cause double process swaps (via OpenURL and then via
306 // transfer). All navigations in this test are same-site, so it only swaps 306 // transfer). All navigations in this test are same-site, so it only swaps
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 360 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
361 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL()); 361 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL());
362 362
363 // Now repeat without replacement. 363 // Now repeat without replacement.
364 GURL url3b = 364 GURL url3b =
365 embedded_test_server()->GetURL("B.com", "/site_isolation/blank.html?3"); 365 embedded_test_server()->GetURL("B.com", "/site_isolation/blank.html?3");
366 GURL url3a = embedded_test_server()->GetURL( 366 GURL url3a = embedded_test_server()->GetURL(
367 "A.com", "/cross-site/" + url3b.host() + url3b.PathForRequest()); 367 "A.com", "/cross-site/" + url3b.host() + url3b.PathForRequest());
368 NavigateToURLContentInitiated(shell(), url3a, false, true); 368 NavigateToURLContentInitiated(shell(), url3a, false, true);
369 369
370 // There should be two history entries. url2b should have replaced url1. url2b 370 // There should be two history entries. url2b should have replaced url1. url3b
371 // should not have replaced url3b. 371 // should not have replaced url2b.
372 EXPECT_TRUE(controller.GetPendingEntry() == nullptr); 372 EXPECT_TRUE(controller.GetPendingEntry() == nullptr);
373 EXPECT_EQ(2, controller.GetEntryCount()); 373 EXPECT_EQ(2, controller.GetEntryCount());
374 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); 374 EXPECT_EQ(1, controller.GetCurrentEntryIndex());
375 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL()); 375 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL());
376 EXPECT_EQ(url3b, controller.GetEntryAtIndex(1)->GetURL()); 376 EXPECT_EQ(url3b, controller.GetEntryAtIndex(1)->GetURL());
377 } 377 }
378 378
379 // Tests that the request is destroyed when a cross process navigation is 379 // Tests that the request is destroyed when a cross process navigation is
380 // cancelled. 380 // cancelled.
381 IN_PROC_BROWSER_TEST_F(CrossSiteTransferTest, NoLeakOnCrossSiteCancel) { 381 IN_PROC_BROWSER_TEST_F(CrossSiteTransferTest, NoLeakOnCrossSiteCancel) {
(...skipping 30 matching lines...) Expand all
412 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 412 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
413 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); 413 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL());
414 414
415 // Make sure the request for url2 did not complete. 415 // Make sure the request for url2 did not complete.
416 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); 416 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted());
417 417
418 shell()->web_contents()->SetDelegate(old_delegate); 418 shell()->web_contents()->SetDelegate(old_delegate);
419 } 419 }
420 420
421 } // namespace content 421 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698