test_bug662170.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <script type="text/javascript" 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. <script type="application/javascript;version=1.7">
  15. /** Test for Bug 662170 **/
  16. SimpleTest.waitForExplicitFinish();
  17. function childLoad() {
  18. // Spin the event loop so we leave the onload handler.
  19. SimpleTest.executeSoon(childLoad2);
  20. }
  21. function childLoad2() {
  22. let cw = $('iframe').contentWindow;
  23. // When we initially load the page, we should be at the top.
  24. is(cw.pageYOffset, 0, 'Initial Y offset should be 0.');
  25. // Scroll the iframe to the bottom.
  26. cw.scrollTo(0, 300);
  27. // Did we actually scroll somewhere?
  28. isnot(Math.round(cw.pageYOffset), 0, 'Y offset should be non-zero after scrolling.');
  29. // Now load file_bug662170.html#, which should take us to the top of the
  30. // page.
  31. cw.location = cw.location + '#';
  32. is(cw.pageYOffset, 0, 'Correct Y offset after loading #.');
  33. SimpleTest.finish();
  34. }
  35. </script>
  36. <!-- When the iframe loads, it calls childLoad(). -->
  37. <iframe height='100px' id='iframe' src='file_bug662170.html'></iframe>
  38. </body>
  39. </html>