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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_controller_impl_unittest.cc
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index eab278b7c0c58baae37273a5599e5d336981fd82..07233e868f9a98b1d2d4c1e330633a45911aa49d 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -415,11 +415,16 @@ TEST_F(NavigationControllerTest, GoToOffset) {
// At step (4), the pending entry for B is discarded, when A is the one that
// is being aborted. This caused the last committed entry to be displayed in
// the omnibox, which is the entry before A was created.
+//
+// PlzNavigate: the test case is slightly different, as the events described
+// above cannot happen in that order. Instead, this tests that receiving a
+// DidFailProvisionalLoad from the renderer that is trying to commit an error
+// 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
TEST_F(NavigationControllerTest, DontDiscardWrongPendingEntry) {
NavigationControllerImpl& controller = controller_impl();
GURL initial_url("http://www.google.com");
- GURL url_1("http://foo.com");
- GURL url_2("http://foo2.com");
+ 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
+ GURL url_2("http://foo.com");
// Navigate inititally. This is the url that could erroneously be the visible
// entry when url_1 fails.
@@ -433,13 +438,22 @@ TEST_F(NavigationControllerTest, DontDiscardWrongPendingEntry) {
main_test_rfh()->SimulateNavigationStart(url_1);
EXPECT_EQ(url_1, controller.GetVisibleEntry()->GetURL());
- // Navigate to url_2, aborting url_1 before the DidStartProvisionalLoad
- // message is received for url_2. Do not discard the pending entry for url_2
- // here.
+ // PlzNavigate: simulate the navigation failing and needing to show an error
+ // page.
+ if (IsBrowserSideNavigationEnabled())
+ 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.
+
+ // Simulate a navigation to url2 starting followed by a DidFailProvsionalLoad
+ // from the navigation to url1.
+ FrameHostMsg_DidFailProvisionalLoadWithError_Params error;
+ 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
+ error.url = url_1;
controller.LoadURL(url_2, Referrer(), ui::PAGE_TRANSITION_TYPED,
std::string());
EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL());
- main_test_rfh()->SimulateNavigationError(url_1, net::ERR_ABORTED);
+ 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.
+ FrameHostMsg_DidFailProvisionalLoadWithError(
+ main_test_rfh()->GetRoutingID(), error));
EXPECT_EQ(url_2, controller.GetVisibleEntry()->GetURL());
// Get the DidStartProvisionalLoad message for url_2.

Powered by Google App Engine
This is Rietveld 408576698