Commit 44f585c8 authored by Arthur Sonzogni's avatar Arthur Sonzogni Committed by Commit Bot

Add regression tests: history.back() called twice.

history.back() called twice causes the browser to navigate back twice.
This is wrong. It should navigate back only once. This CL adds
regression tests.

The specification says the following:
---
If there is an ongoing attempt to navigate specified browsing context
that has not yet matured (i.e. it has not passed the point of making its
Document the active document), then cancel that attempt to navigate the
browsing context.
---

Specification:
https://html.spec.whatwg.org/multipage/history.html#traverse-the-history-by-a-delta

Bug: 869710
Change-Id: I1534c7a04dbd220920970576baad02cedfaf6a12
Reviewed-on: https://chromium-review.googlesource.com/1215803
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593553}
parent f0179abf
......@@ -8197,4 +8197,44 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
}
}
// history.back() called twice in the renderer process should not make the user
// navigate back twice.
// Regression test for https://crbug.com/869710
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
HistoryBackTwiceFromRendererWithoutUserGesture) {
GURL url1(embedded_test_server()->GetURL("a.com", "/title1.html"));
GURL url2(embedded_test_server()->GetURL("b.com", "/title2.html"));
GURL url3(embedded_test_server()->GetURL("c.com", "/title3.html"));
EXPECT_TRUE(NavigateToURL(shell(), url1));
EXPECT_TRUE(NavigateToURL(shell(), url2));
EXPECT_TRUE(NavigateToURL(shell(), url3));
EXPECT_TRUE(ExecuteScriptWithoutUserGesture(
shell(), "history.back(); history.back();"));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
EXPECT_EQ(url2, shell()->web_contents()->GetLastCommittedURL());
}
// history.back() called twice in the renderer process should not make the user
// navigate back twice. Even with a user gesture.
// Regression test for https://crbug.com/869710
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
HistoryBackTwiceFromRendererWithUserGesture) {
GURL url1(embedded_test_server()->GetURL("a.com", "/title1.html"));
GURL url2(embedded_test_server()->GetURL("b.com", "/title2.html"));
GURL url3(embedded_test_server()->GetURL("c.com", "/title3.html"));
EXPECT_TRUE(NavigateToURL(shell(), url1));
EXPECT_TRUE(NavigateToURL(shell(), url2));
EXPECT_TRUE(NavigateToURL(shell(), url3));
EXPECT_TRUE(ExecuteScript(shell(), "history.back(); history.back();"));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// TODO(https://crbug.com/869710): This should be url2.
EXPECT_EQ(url1, shell()->web_contents()->GetLastCommittedURL());
}
} // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment