Unit Test for the fix for history.replaceState navigations submitted earlier.

Unit test for the fix submitted with https://codereview.chromium.org/316553007

BUG=375921

Review URL: https://codereview.chromium.org/316403004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276770 0039d316-1c4b-4281-b951-d872f2087c98
parent b5632692
...@@ -555,6 +555,34 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, ...@@ -555,6 +555,34 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest,
EXPECT_EQ(NULL, screenshot_manager()->screenshot_taken_for()); EXPECT_EQ(NULL, screenshot_manager()->screenshot_taken_for());
} }
// Tests that navigations resulting from reloads and history.replaceState
// do not capture screenshots while navigations resulting from
// histrory.pushState do.
IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, ReplaceStateReloadPushState) {
ASSERT_NO_FATAL_FAILURE(
StartTestWithPage("files/overscroll_navigation.html"));
WebContentsImpl* web_contents =
static_cast<WebContentsImpl*>(shell()->web_contents());
RenderFrameHost* main_frame = web_contents->GetMainFrame();
set_min_screenshot_interval(0);
screenshot_manager()->Reset();
ExecuteSyncJSFunction(main_frame, "use_replace_state()");
screenshot_manager()->WaitUntilScreenshotIsReady();
// history.replaceState shouldn't capture a screenshot
EXPECT_FALSE(screenshot_manager()->screenshot_taken_for());
screenshot_manager()->Reset();
web_contents->GetController().Reload(true);
WaitForLoadStop(web_contents);
// reloading the page shouldn't capture a screenshot
EXPECT_FALSE(screenshot_manager()->screenshot_taken_for());
screenshot_manager()->Reset();
ExecuteSyncJSFunction(main_frame, "use_push_state()");
screenshot_manager()->WaitUntilScreenshotIsReady();
// pushing a state should capture a screenshot
EXPECT_TRUE(screenshot_manager()->screenshot_taken_for());
}
// TODO(sadrul): This test is disabled because it reparents in a way the // TODO(sadrul): This test is disabled because it reparents in a way the
// FocusController does not support. This code would crash in // FocusController does not support. This code would crash in
// a production build. It only passed prior to this revision // a production build. It only passed prior to this revision
......
...@@ -57,6 +57,14 @@ function uninstall_touch_handler() { ...@@ -57,6 +57,14 @@ function uninstall_touch_handler() {
document.removeEventListener('touchstart', touch_start_handler); document.removeEventListener('touchstart', touch_start_handler);
} }
function use_replace_state() {
window.history.replaceState({}, 'foo');
}
function use_push_state() {
window.history.pushState({}, 'foo2');
}
onload = function() { onload = function() {
window.onhashchange = function() { window.onhashchange = function() {
document.title = "Title: " + location.hash; document.title = "Title: " + location.hash;
......
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