test_scroll_position_restore.html (1322B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1269539 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1269539</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="/tests/SimpleTest/paint_listener.js"></script> 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 12 </head> 13 <body> 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1269539">Mozilla Bug 1269539</a> 15 <p id="display"></p> 16 <script> 17 SimpleTest.waitForExplicitFinish(); 18 19 var loadCount = 0; 20 var childWin = window.open('file_scroll_position_restore.html', '_blank'); 21 22 function handleLoad() { 23 if (loadCount == 0) { 24 loadCount++; 25 childWin.scrollTo(0, childWin.scrollMaxY); 26 childWin.waitForAllPaintsFlushed(function() { 27 childWin.location.reload(); 28 }); 29 } else { 30 childWin.waitForAllPaintsFlushed(function() { 31 // Verify that the scroll position was retained. 32 // NOTE: Window.scrollMaY is a long value, so we need to round 33 // Window.scrollY which is double. 34 // NOTE: Window.scrollMaxY is non-standard, so difference < 1.0 would not 35 // be a big problem. 36 is(Math.round(childWin.scrollY), childWin.scrollMaxY); 37 childWin.close(); 38 SimpleTest.finish(); 39 }); 40 } 41 } 42 43 </script> 44 </body> 45 </html>