Index: LayoutTests/fast/loader/scroll-position-restoration-without-premature-clamping.html |
diff --git a/LayoutTests/fast/loader/scroll-position-restoration-without-premature-clamping.html b/LayoutTests/fast/loader/scroll-position-restoration-without-premature-clamping.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e0dbf937754337f43739f8cb87d4a5b5e4a8fa01 |
--- /dev/null |
+++ b/LayoutTests/fast/loader/scroll-position-restoration-without-premature-clamping.html |
@@ -0,0 +1,56 @@ |
+<!DOCTYPE html> |
+<style> |
+/* Body is large enough to scroll but not enough to restore the scroll |
+ position without clamping. */ |
+body { |
+ height: 2000px; |
+ width: 2000px; |
+} |
+</style> |
+ |
+<div id='console'></div> |
+ |
+<script src="../../resources/js-test.js"></script> |
+<script> |
+jsTestIsAsync = true |
+setPrintTestResultsLazily(); |
+description('Test ensures that frame scroll position is not prematurely ' + |
+ 'clamped and restored before load event fires.'); |
+ |
+// Forcing layout causes the frame to attempt to restore scroll position if |
+// possible even before page loading is complete. |
+forceLayout(); |
+debug('Scroll position should not be clamped and restored while frame is loading'); |
+shouldBe('document.scrollingElement.scrollLeft', '0'); |
+shouldBe('document.scrollingElement.scrollTop', '0'); |
+ |
+onload = function() { |
+ if (window.name == 'verification') { |
+ shouldBe('document.scrollingElement.scrollLeft', '5000'); |
+ shouldBe('document.scrollingElement.scrollTop', '5001'); |
+ |
+ window.name = ""; |
+ setTimeout(function(){ window.scrollTo(0, 0); }, 0); |
+ finishJSTest(); |
+ } else { |
+ window.scrollTo(5000, 5001); |
+ shouldBe('document.scrollingElement.scrollLeft', '5000'); |
+ shouldBe('document.scrollingElement.scrollTop', '5001'); |
+ setTimeout(function(){ |
+ window.name = "verification"; |
+ window.location = "data:text/html,<script>history.back();</scr" + "ipt>"; |
+ }, 0); |
+ } |
+} |
+ |
+function forceLayout () { |
+ document.body.scrollTop; |
+} |
+</script> |
+ |
+<style> |
+body { |
+ height: 9999px; |
+ width: 9999px; |
+} |
+</style> |