test_bug662170.html (1405B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=662170 5 --> 6 <head> 7 <title>Test for Bug 662170</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/WindowSnapshot.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=662170">Mozilla Bug 662170</a> 14 15 <script type="application/javascript"> 16 17 /** Test for Bug 662170 */ 18 SimpleTest.waitForExplicitFinish(); 19 20 function childLoad() { 21 // Spin the event loop so we leave the onload handler. 22 SimpleTest.executeSoon(childLoad2); 23 } 24 25 function childLoad2() { 26 let cw = $("iframe").contentWindow; 27 28 // When we initially load the page, we should be at the top. 29 is(cw.pageYOffset, 0, "Initial Y offset should be 0."); 30 31 // Scroll the iframe to the bottom. 32 cw.scrollTo(0, 300); 33 34 // Did we actually scroll somewhere? 35 isnot(Math.round(cw.pageYOffset), 0, "Y offset should be non-zero after scrolling."); 36 37 // Now load file_bug662170.html#, which should take us to the top of the 38 // page. 39 cw.location = cw.location + "#"; 40 41 is(cw.pageYOffset, 0, "Correct Y offset after loading #."); 42 SimpleTest.finish(); 43 } 44 45 </script> 46 47 <!-- When the iframe loads, it calls childLoad(). --> 48 <iframe height='100px' id='iframe' src='file_bug662170.html'></iframe> 49 50 </body> 51 </html>