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

Unified Diff: LayoutTests/fast/loader/scroll-position-restored-on-reload-at-load-event.html

Issue 52893003: scrollTop and scrollLeft always 0 in DOMContentLoaded handler on a scrolled page (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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-restored-on-reload-at-load-event.html
diff --git a/LayoutTests/fast/loader/scroll-position-restored-on-reload-at-load-event.html b/LayoutTests/fast/loader/scroll-position-restored-on-reload-at-load-event.html
new file mode 100644
index 0000000000000000000000000000000000000000..81fd111f4ca69099abdf45fe40b0447d6ad39613
--- /dev/null
+++ b/LayoutTests/fast/loader/scroll-position-restored-on-reload-at-load-event.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src="../js/resources/js-test-pre.js"></script>
+ <script>
+ description('Test ensures that documentElement.scrollTop/Left properties are available by the time DOMContentLoaded event fires.');
+ // Navigation steps:
+ // 1- page gets first loaded and scrolled.
+ // 2- reload is performed.
+ // Test: ensure that by the time DOMContenLoaded fires (after a reload navigation), documentElement.scrollTop/Left are set.
+ // 3- navigate away and then back again.
+ // Test: ensure that by the time DOMContenLoaded fires (after a back navigation), documentElement.scrollTop/Left are set.
+
+ function init(evt) {
+ if (window.name == 'second/load') {
+ shouldBe('document.documentElement.scrollTop', '1000');
+ shouldBe('document.documentElement.scrollLeft', '1000');
+
+ window.name = "third/load";
+ setTimeout('window.location = "data:text/html,<script>history.back();</scr" + "ipt>"', 0);
+ } else if (window.name == 'third/load') {
+ // Returned back.
+ window.name = "";
+ shouldBe('document.documentElement.scrollTop', '1000');
+ shouldBe('document.documentElement.scrollLeft', '1000');
+
+ if (window.testRunner)
+ finishJSTest();
+ } else {
+ window.scrollTo(1000, 1000);
+ window.name = "second/load";
+ setTimeout('location.reload()', 0);
+ }
+ }
+
+ window.addEventListener('DOMContentLoaded', init, true);
+ window.onunload = function() {} // prevent caching
+
+ var jsTestIsAsync = true;
+ </script>
+ <body>
+ <div style='width: 9999px; height:9999px; float:left;'></div>
+ <h1 id='console'/>
+ </body>
+ <script src="../js/resources/js-test-post.js"></script>
+</html>

Powered by Google App Engine
This is Rietveld 408576698