Index: third_party/WebKit/LayoutTests/imported/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html |
diff --git a/third_party/WebKit/LayoutTests/fast/history/scroll-restoration/scroll-restoration-push-replace.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html |
similarity index 54% |
copy from third_party/WebKit/LayoutTests/fast/history/scroll-restoration/scroll-restoration-push-replace.html |
copy to third_party/WebKit/LayoutTests/imported/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html |
index 88537534df61b8c61038f910c146bf4be16d6108..ee10ca71d2df66141d4f623556e9b9e37d87338f 100644 |
--- a/third_party/WebKit/LayoutTests/fast/history/scroll-restoration/scroll-restoration-push-replace.html |
+++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html |
@@ -1,4 +1,6 @@ |
<!DOCTYPE html> |
+<title>Correct behaviour of scroll restoration mode in same document history traversals</title> |
+ |
<style> |
body { |
height: 10000px; |
@@ -7,8 +9,8 @@ |
</style> |
<body></body> |
-<script src="../../../resources/testharness.js"></script> |
-<script src="../../../resources/testharnessreport.js"></script> |
+<script src="../../../../../../../resources/testharness.js"></script> |
+<script src="../../../../../../../resources/testharnessreport.js"></script> |
<script type="text/javascript"> |
'use strict'; |
@@ -16,13 +18,16 @@ |
history.scrollRestoration = 'auto'; |
window.scrollTo(0, 0); |
- // create history entries and then verify the impact of scrollRestoration |
+ // create history entries and then verify the impact of scrollRestoration |
// when they are popped |
var entries = { |
- /* TODO: spec does not defines behavior of 'auto' so we should not expect scroll position for these */ |
- '#1': {type: 'push', expectedScroll: [50, 100], scrollRestoration: 'auto'}, |
- '#2': {type: 'replace', expectedScroll: [100, 200], scrollRestoration: 'auto'}, |
- /* Scroll position should not be restored for these. */ |
+ /* For scroll restoration mode 'auto', the spec does not require scroll |
+ position to be restored at any particular value. */ |
+ '#1': {type: 'push', expectedScroll: null, scrollRestoration: 'auto'}, |
+ '#2': {type: 'replace', expectedScroll: null, scrollRestoration: 'auto'}, |
+ /* For scroll restoration mode 'manual', the spec requires scroll position |
+ not to be restored. So we expect [555,555] which is the latest position |
+ before navigation. */ |
'#3': {type: 'push', expectedScroll: [555, 555], scrollRestoration: 'manual'}, |
'#4': {type: 'replace', expectedScroll: [555, 555], scrollRestoration: 'manual'} |
}; |
@@ -40,9 +45,9 @@ |
history.pushState(null, '', key); |
history.replaceState.apply(history, args); |
} |
- assert_equals(history.scrollRestoration, beforeValue, `${entry.type} retain current history.scrollRestoration value`); |
+ assert_equals(history.scrollRestoration, beforeValue, `history.scrollRestoration value is retained after pushing new state`); |
history.scrollRestoration = newValue; |
- assert_equals(history.scrollRestoration, newValue, `Setting scrollRestoration to ${newValue} does expected`); |
+ assert_equals(history.scrollRestoration, newValue, `Setting scrollRestoration to ${newValue} works as expected`); |
window.scrollBy(50, 100); |
} |
@@ -55,10 +60,12 @@ |
t.done(); |
return; |
} |
- console.log(`verifying ${key}`); |
assert_equals(history.state.key, key, `state should have key: ${key}`); |
- assert_equals(document.scrollingElement.scrollLeft, entry.expectedScroll[0], `scrollLeft is correct for ${key}`); |
- assert_equals(document.scrollingElement.scrollTop, entry.expectedScroll[1], `scrollTop is correct ${key}`); |
+ assert_equals(history.scrollRestoration, entry.scrollRestoration, 'scrollRestoration is updated correctly'); |
+ if (entry.expectedScroll) { |
+ assert_equals(window.scrollX, entry.expectedScroll[0], `scrollX is correct for ${key}`); |
+ assert_equals(window.scrollY, entry.expectedScroll[1], `scrollY is correct for ${key}`); |
+ } |
window.history.back(); |
})); |
@@ -70,5 +77,5 @@ |
window.history.back(); |
}, 0); |
- }, 'history.{push,replace}State retain and respect history.scrollRestoration'); |
+ }, 'history.{push,replace}State retain scroll restoration mode and navigation in the same document respects it'); |
</script> |