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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <style>
3 body {
4 height: 2000px;
5 width: 2000px;
6 }
7 </style>
8
9 <div id='console'></div>
10 <script src="../../resources/js-test.js"></script>
11 <script>
12 window.jsTestIsAsync = true;
13 description('This test verifies that navigating to entries created by ' +
14 'pushState or replaceState does not restore scroll position.');
15
16 // Navigation steps:
17 // 1. Create a history entry using pushState then scroll
18 // 2. Create a history entry and replace it then scroll
19 // 3. Navigate away and come back to #2 and verify
20 // 4. Navigate back one more time to #1 and verify
21 function handleNavigation() {
22 if (window.name !== 'verification phase') {
23 history.pushState({}, "", "#1");
24 window.scrollBy(50, 100);
25
26 history.pushState({}, "", "#2");
27 history.replaceState({foo: 'bar'}, "", "#2");
28 window.scrollBy(50, 100);
29
30 setTimeout(function() {
31 window.name = 'verification phase';
32 window.location.href = 'resources/empty-document-goes-back.html';
33 }, 0);
34 } else {
35 // The scroll position should not be restored
36 debug('verifying ' + location.hash);
37 shouldBe('document.body.scrollTop', '0');
38 shouldBe('document.body.scrollLeft', '0');
39
40 if (location.hash === '#2') {
41 window.history.back();
42 } else {
43 window.name = "";
44 finishJSTest();
45 }
46 }
47 }
48
49 window.addEventListener('pageshow', handleNavigation);
50 window.addEventListener('hashchange', handleNavigation);
51 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698