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

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

Issue 1872313003: PlzNavigate: don't discard pending entry in DidFailProvisionalLoad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + addressed comments Created 4 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/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // as follows: 408 // as follows:
409 // 1. Pending entry for A is created. 409 // 1. Pending entry for A is created.
410 // 2. DidStartProvisionalLoad message for A arrives. 410 // 2. DidStartProvisionalLoad message for A arrives.
411 // 3. Pending entry for B is created. 411 // 3. Pending entry for B is created.
412 // 4. DidFailProvisionalLoad message for A arrives. The logic here discards. 412 // 4. DidFailProvisionalLoad message for A arrives. The logic here discards.
413 // 5. DidStartProvisionalLoad message for B arrives. 413 // 5. DidStartProvisionalLoad message for B arrives.
414 // 414 //
415 // At step (4), the pending entry for B is discarded, when A is the one that 415 // At step (4), the pending entry for B is discarded, when A is the one that
416 // is being aborted. This caused the last committed entry to be displayed in 416 // is being aborted. This caused the last committed entry to be displayed in
417 // the omnibox, which is the entry before A was created. 417 // the omnibox, which is the entry before A was created.
418 //
419 // PlzNavigate: the test case is slightly different, as the events described
420 // above cannot happen in that order. Instead, this tests that receiving a
421 // DidFailProvisionalLoad from the renderer that is trying to commit an error
422 // page won't reset the pending entry of a navigation that just started.
Charlie Reis 2016/04/12 23:59:16 Thanks for adding a test for this! I feel like it
clamy 2016/04/13 12:51:51 Done. They are now separate, and I skip this one w
418 TEST_F(NavigationControllerTest, DontDiscardWrongPendingEntry) { 423 TEST_F(NavigationControllerTest, DontDiscardWrongPendingEntry) {
419 NavigationControllerImpl& controller = controller_impl(); 424 NavigationControllerImpl& controller = controller_impl();
420 GURL initial_url("http://www.google.com"); 425 GURL initial_url("http://www.google.com");
421 GURL url_1("http://foo.com"); 426 GURL url_1("http://www.google.com/foo");
clamy 2016/04/12 14:08:02 I had to make a few changes to make the test pass
Charlie Reis 2016/04/12 23:59:17 Seems ok. (I'm not 100% sure whether the original
422 GURL url_2("http://foo2.com"); 427 GURL url_2("http://foo.com");
423 428
424 // Navigate inititally. This is the url that could erroneously be the visible 429 // Navigate inititally. This is the url that could erroneously be the visible
425 // entry when url_1 fails. 430 // entry when url_1 fails.
426 NavigateAndCommit(initial_url); 431 NavigateAndCommit(initial_url);
427 432
428 // Set the pending entry as url_1 and receive the DidStartProvisionalLoad 433 // Set the pending entry as url_1 and receive the DidStartProvisionalLoad
429 // message, creating the NavigationHandle. 434 // message, creating the NavigationHandle.
430 controller.LoadURL(url_1, Referrer(), ui::PAGE_TRANSITION_TYPED, 435 controller.LoadURL(url_1, Referrer(), ui::PAGE_TRANSITION_TYPED,
431 std::string()); 436 std::string());
432 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); 437 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL());
433 main_test_rfh()->SimulateNavigationStart(url_1); 438 main_test_rfh()->SimulateNavigationStart(url_1);
434 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL()); 439 EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL());
435 440
436 // Navigate to url_2, aborting url_1 before the DidStartProvisionalLoad 441 // PlzNavigate: simulate the navigation failing and needing to show an error
437 // message is received for url_2. Do not discard the pending entry for url_2 442 // page.
438 // here. 443 if (IsBrowserSideNavigationEnabled())
444 main_test_rfh()->SimulateNavigationError(url_1, net::ERR_TIMED_OUT);
clamy 2016/04/12 14:08:02 We need to get the navigation to fail here with Pl
Charlie Reis 2016/04/12 23:59:16 Acknowledged.
445
446 // Simulate a navigation to url2 starting followed by a DidFailProvsionalLoad
447 // from the navigation to url1.
448 FrameHostMsg_DidFailProvisionalLoadWithError_Params error;
449 error.error_code = net::ERR_TIMED_OUT;
clamy 2016/04/12 14:08:02 Matching error here with the PlzNavigate case.
Charlie Reis 2016/04/12 23:59:16 Shouldn't it be ERR_ABORTED in the non-PlzNavigate
450 error.url = url_1;
439 controller.LoadURL(url_2, Referrer(), ui::PAGE_TRANSITION_TYPED, 451 controller.LoadURL(url_2, Referrer(), ui::PAGE_TRANSITION_TYPED,
440 std::string()); 452 std::string());
441 EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL()); 453 EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL());
442 main_test_rfh()->SimulateNavigationError(url_1, net::ERR_ABORTED); 454 main_test_rfh()->OnMessageReceived(
clamy 2016/04/12 14:08:02 We just want to simulate getting the DidFailProvis
Charlie Reis 2016/04/12 23:59:16 Acknowledged.
455 FrameHostMsg_DidFailProvisionalLoadWithError(
456 main_test_rfh()->GetRoutingID(), error));
443 EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL()); 457 EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL());
444 458
445 // Get the DidStartProvisionalLoad message for url_2. 459 // Get the DidStartProvisionalLoad message for url_2.
446 main_test_rfh()->SimulateNavigationStart(url_2); 460 main_test_rfh()->SimulateNavigationStart(url_2);
447 461
448 EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL()); 462 EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL());
449 } 463 }
450 464
451 TEST_F(NavigationControllerTest, LoadURL) { 465 TEST_F(NavigationControllerTest, LoadURL) {
452 NavigationControllerImpl& controller = controller_impl(); 466 NavigationControllerImpl& controller = controller_impl();
(...skipping 4784 matching lines...) Expand 10 before | Expand all | Expand 10 after
5237 EXPECT_EQ(default_ssl_status.content_status, 5251 EXPECT_EQ(default_ssl_status.content_status,
5238 observer.details().ssl_status.content_status); 5252 observer.details().ssl_status.content_status);
5239 EXPECT_EQ( 5253 EXPECT_EQ(
5240 0u, 5254 0u,
5241 observer.details().ssl_status.signed_certificate_timestamp_ids.size()); 5255 observer.details().ssl_status.signed_certificate_timestamp_ids.size());
5242 5256
5243 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); 5257 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count());
5244 } 5258 }
5245 5259
5246 } // namespace content 5260 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698