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

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

Issue 902083002: Only increment the history list offset if we are not replacing the current item. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: with test Created 5 years, 10 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 d9bdc38c4fb7c48a60066a392f95075e400be489..ed3c374539884af3d0f1c60981daf0b09accd403 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -13,6 +13,7 @@
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
+#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "content/test/content_browser_test_utils_internal.h"
@@ -88,6 +89,57 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
controller.GetLastCommittedEntry()->GetURL());
}
+namespace {
+
+int RendererHistoryLength(Shell* shell) {
+ int value = 0;
+ EXPECT_TRUE(ExecuteScriptAndExtractInt(
+ shell->web_contents(),
+ "domAutomationController.send(history.length)",
+ &value));
+ return value;
+}
+
+// Similar to the ones from content_browser_test_utils.
+bool NavigateToURLAndReplace(Shell* shell, const GURL& url) {
+ WebContents* web_contents = shell->web_contents();
+ WaitForLoadStop(web_contents);
+ TestNavigationObserver same_tab_observer(web_contents, 1);
+ NavigationController::LoadURLParams params(url);
+ params.should_replace_current_entry = true;
+ web_contents->GetController().LoadURLWithParams(params);
+ web_contents->Focus();
Charlie Reis 2015/02/06 17:29:35 Is this line needed? I don't see why the focus wo
Avi (use Gerrit) 2015/02/06 17:43:14 In content_browser_test_utils, NavigateToURLBlockU
+ same_tab_observer.Wait();
+ if (!IsLastCommittedEntryOfPageType(web_contents, PAGE_TYPE_NORMAL))
+ return false;
+ return web_contents->GetLastCommittedURL() == url;
+}
+
+} // namespace
+
+// When loading a new page to replace an old page in the history list, make sure
+// that the browser and renderer agree, and that both get it right.
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ CorrectLengthWithCurrentItemReplacement) {
+ NavigationController& controller =
+ shell()->web_contents()->GetController();
+
+ EXPECT_TRUE(NavigateToURL(shell(), GURL("data:text/html,page1")));
+ EXPECT_EQ(1, controller.GetEntryCount());
+ EXPECT_EQ(1, RendererHistoryLength(shell()));
+
+ EXPECT_TRUE(NavigateToURLAndReplace(shell(), GURL("data:text/html,page2")));
+ EXPECT_EQ(1, controller.GetEntryCount());
+ EXPECT_EQ(1, RendererHistoryLength(shell()));
+
+ // Note that there's no way to access the renderer's notion of the history
+ // offset via JavaScript. Checking just the history length, though, is enough;
+ // if the replacement failed, there would be a new history entry and thus an
+ // incorrect length.
+}
+
+namespace {
+
struct FrameNavigateParamsCapturer : public WebContentsObserver {
public:
explicit FrameNavigateParamsCapturer(FrameTreeNode* node)
@@ -135,6 +187,8 @@ struct FrameNavigateParamsCapturer : public WebContentsObserver {
scoped_refptr<MessageLoopRunner> message_loop_runner_;
};
+} // namespace
+
// Verify that the distinction between manual and auto subframes is properly set
// for subframe navigations. 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