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

Unified Diff: LayoutTests/fast/loader/scroll-position-not-restored-for-history-api.html

Issue 927213004: Accept options in history APIs to allow scroll restoration to be disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Improve the 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
Index: LayoutTests/fast/loader/scroll-position-not-restored-for-history-api.html
diff --git a/LayoutTests/fast/loader/scroll-position-not-restored-for-history-api.html b/LayoutTests/fast/loader/scroll-position-not-restored-for-history-api.html
new file mode 100644
index 0000000000000000000000000000000000000000..5b331fba1288790f2f98cc86be79fa24899eb070
--- /dev/null
+++ b/LayoutTests/fast/loader/scroll-position-not-restored-for-history-api.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<style>
+body {
+ height: 2000px;
+ width: 2000px;
+}
+</style>
+
+<div id='console'></div>
+<script src="../../resources/js-test.js"></script>
+<script>
+window.jsTestIsAsync = true;
+description('This test verifies that navigating to entries created by ' +
+ 'pushState or replaceState does not restore scroll position.');
+
+// Navigation steps:
+// 1. Create a history entry using pushState then scroll
+// 2. Create a history entry and replace it then scroll
+// 3. Navigate away and come back to #2 and verify
+// 4. Navigate back one more time to #1 and verify
+function handleNavigation() {
+ if (window.name !== 'verification phase') {
+ history.pushState({}, "", "#1");
+ window.scrollBy(50, 100);
+
+ history.pushState({}, "", "#2");
+ history.replaceState({foo: 'bar'}, "", "#2");
+ window.scrollBy(50, 100);
+
+ setTimeout(function() {
+ window.name = 'verification phase';
+ window.location.href = 'resources/empty-document-goes-back.html';
+ }, 0);
+ } else {
+ // The scroll position should not be restored
+ debug('verifying ' + location.hash);
+ shouldBe('document.body.scrollTop', '0');
+ shouldBe('document.body.scrollLeft', '0');
+
+ if (location.hash === '#2') {
+ window.history.back();
+ } else {
+ window.name = "";
+ finishJSTest();
+ }
+ }
+}
+
+window.addEventListener('pageshow', handleNavigation);
+window.addEventListener('hashchange', handleNavigation);
+</script>

Powered by Google App Engine
This is Rietveld 408576698