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

Unified Diff: third_party/WebKit/LayoutTests/fast/loader/scroll-restore-should-happen-during-load.html

Issue 1561573004: Fix bug where scroll position was being restored after navigation completes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore to previous type Created 4 years, 11 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 | third_party/WebKit/LayoutTests/fast/loader/scroll-restore-should-happen-during-load-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/loader/scroll-restore-should-happen-during-load.html
diff --git a/third_party/WebKit/LayoutTests/fast/loader/scroll-restore-should-happen-during-load.html b/third_party/WebKit/LayoutTests/fast/loader/scroll-restore-should-happen-during-load.html
new file mode 100644
index 0000000000000000000000000000000000000000..13437bdd31552fd6157df715c03cd75d2ef8a235
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/loader/scroll-restore-should-happen-during-load.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<style>
+#content {
+ height: 2000px;
+ width: 2000px;
+}
+</style>
+
+<div id='console'></div>
+<div id='content'></div>
+
+<script src="../../resources/js-test.js"></script>
+<script>
+jsTestIsAsync = true;
+setPrintTestResultsLazily();
+description('Test ensures that frame scroll position is only restored during ' +
+ 'the navigation process but does not occur after navigation is ' +
+ 'complete for same document navigations.');
+
+window.scrollTo(100, 100);
+history.pushState(null, null, '#test');
+
+window.addEventListener('hashchange', _ => {
+ // after back navigation scroll position should be restored to 100,100.
+ debug('Verify that scroll position restored correctly during navigation.');
+ shouldBe('document.scrollingElement.scrollLeft', '100');
+ shouldBe('document.scrollingElement.scrollTop', '100');
+
+ // trigger a content size change that should cause the scroll position
+ // to get clamped to 0,0.
+ document.getElementById('content').style.display = 'none';
+ shouldBe('document.scrollingElement.scrollLeft', '0');
+ shouldBe('document.scrollingElement.scrollTop', '0');
+
+ // trigger another content size change and verify that scroll position is
+ // not restored.
+ debug('Verify that scroll position is not restored again after navigation is complete.');
+ document.getElementById('content').style.display = 'block';
+ shouldBe('document.scrollingElement.scrollLeft', '0');
+ shouldBe('document.scrollingElement.scrollTop', '0');
+
+ finishJSTest();
+});
+
+setTimeout(_ => {
+ window.scrollTo(0, 0);
+ shouldBe('document.scrollingElement.scrollLeft', '0');
+ shouldBe('document.scrollingElement.scrollTop', '0');
+ history.back();
+}, 0);
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/loader/scroll-restore-should-happen-during-load-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698