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

Unified Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 1048963002: Fix incorrect creation of duplicate navigation entries for repeated page load failures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@committype3
Patch Set: more test Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigation_controller_impl_browsertest.cc
diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
index 997a6fdb051ae3ebcf6f6b1de0119286ea08b846..4c6b981e7dfa3d36df746939e32ce7e5a3ea2d23 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -25,6 +25,7 @@
#include "content/test/content_browser_test_utils_internal.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
+#include "net/test/url_request/url_request_failed_job.h"
namespace content {
@@ -376,6 +377,63 @@ class LoadCommittedCapturer : public WebContentsObserver {
} // namespace
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ ErrorPageReplacement) {
+ NavigationController& controller = shell()->web_contents()->GetController();
+ GURL error_url(
+ net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_RESET));
+ net::URLRequestFailedJob::AddUrlHandler();
+
+ NavigateToURL(shell(), GURL(url::kAboutBlankURL));
+ EXPECT_EQ(1, controller.GetEntryCount());
+
+ FrameTreeNode* root =
+ static_cast<WebContentsImpl*>(shell()->web_contents())->
+ GetFrameTree()->root();
+
+ // Navigate to a page that fails to load. It must result in an error page, the
+ // NEW_PAGE navigation type, and an addition to the history list.
+ {
+ FrameNavigateParamsCapturer capturer(root);
+ NavigateFrameToURL(root, error_url);
+ capturer.Wait();
+ EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type);
+ NavigationEntry* entry = controller.GetLastCommittedEntry();
+ EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType());
+ EXPECT_EQ(2, controller.GetEntryCount());
+ }
+
+ // Navigate again to the page that fails to load. It must result in an error
+ // page, the EXISTING_PAGE navigation type, and no addition to the history
+ // list. We do not use SAME_PAGE here; that case only differs in that it
+ // clears the pending entry, and there is no pending entry after a load
+ // failure.
+ {
+ FrameNavigateParamsCapturer capturer(root);
+ NavigateFrameToURL(root, error_url);
+ capturer.Wait();
+ EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type);
+ NavigationEntry* entry = controller.GetLastCommittedEntry();
+ EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType());
+ EXPECT_EQ(2, controller.GetEntryCount());
+ }
+
+ // Make a new entry ...
+ NavigateToURL(shell(), GURL(url::kAboutBlankURL));
+ EXPECT_EQ(3, controller.GetEntryCount());
+
+ // ... and replace it.
+ {
+ FrameNavigateParamsCapturer capturer(root);
+ NavigateToURLAndReplace(shell(), error_url);
+ capturer.Wait();
+ EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type);
+ NavigationEntry* entry = controller.GetLastCommittedEntry();
+ EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType());
+ EXPECT_EQ(3, controller.GetEntryCount());
+ }
davidben 2015/03/31 17:26:08 There's a third case that's probably worth testing
Charlie Reis 2015/03/31 17:29:48 It looks like that's what NavigateToURLAndReplace
+}
+
// Various tests for navigation type classifications. TODO(avi): It's rather
// bogus that the same info is in two different enums; http://crbug.com/453555.
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698