PageRenderTime 63ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/docshell/test/navigation/test_bug430723.html

https://github.com/zpao/v8monkey
HTML | 140 lines | 111 code | 26 blank | 3 comment | 0 complexity | 4c68ca0c1b525752b7b27d2b73783c92 MD5 | raw file
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=430723
  5. -->
  6. <head>
  7. <title>Test for Bug 430723</title>
  8. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <script type="text/javascript" src="/tests/SimpleTest/EventUtils.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=430723">Mozilla Bug 430723</a>
  14. <p id="display"></p>
  15. <div id="content" style="display: none">
  16. </div>
  17. <pre id="test">
  18. <script class="testbody" type="text/javascript">
  19. //<![CDATA[
  20. /** Test for Bug 430723 **/
  21. var gTallRedBoxURI = "data:text/html;charset=utf-8;base64,PGh0bWw%2BPGhlYWQ%2BPHNjcmlwdD53aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcigncGFnZXNob3cnLCBmdW5jdGlvbigpe29wZW5lci5uZXh0VGVzdCgpO30sIGZhbHNlKTs8L3NjcmlwdD48L2hlYWQ%2BPGJvZHk%2BPGRpdiBzdHlsZT0icG9zaXRpb246YWJzb2x1dGU7IGxlZnQ6MHB4OyB0b3A6MHB4OyB3aWR0aDo1MCU7IGhlaWdodDoxNTAlOyBiYWNrZ3JvdW5kLWNvbG9yOnJlZCI%2BPHA%2BVGhpcyBpcyBhIHZlcnkgdGFsbCByZWQgYm94LjwvcD48L2Rpdj48L2JvZHk%2BPC9odG1sPg%3D%3D";
  22. // <html><head>
  23. // < script > window.addEventListener("pageshow", function(){opener.nextTest();}, false); < /script >
  24. // </head><body>
  25. // <div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:red">
  26. // <p>This is a very tall red box.</p>
  27. // </div></body></html>
  28. var gTallBlueBoxURI = "data:text/html;charset=utf-8;base64,PGh0bWw%2BPGhlYWQ%2BPHNjcmlwdD53aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcigncGFnZXNob3cnLCBmdW5jdGlvbigpe29wZW5lci5uZXh0VGVzdCgpO30sIGZhbHNlKTs8L3NjcmlwdD48L2hlYWQ%2BPGJvZHk%2BPGRpdiBzdHlsZT0icG9zaXRpb246YWJzb2x1dGU7IGxlZnQ6MHB4OyB0b3A6MHB4OyB3aWR0aDo1MCU7IGhlaWdodDoxNTAlOyBiYWNrZ3JvdW5kLWNvbG9yOmJsdWUiPjxwPlRoaXMgaXMgYSB2ZXJ5IHRhbGwgYmx1ZSBib3guPC9wPjwvZGl2PjwvYm9keT48L2h0bWw%2B";
  29. // <html><head>
  30. // < script > window.addEventListener("pageshow", function(){opener.nextTest();}, false); < /script >
  31. // </head><body>
  32. // <div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:blue">
  33. // <p>This is a very tall blue box.</p>
  34. // </div></body></html>
  35. window.onload = runTest;
  36. var testWindow;
  37. var testNum = 0;
  38. var smoothScrollPref = "general.smoothScroll";
  39. function runTest() {
  40. SpecialPowers.setBoolPref(smoothScrollPref, false);
  41. testWindow = window.open(gTallRedBoxURI, "testWindow", "width=300,height=300,location=yes,scrollbars=yes");
  42. }
  43. var nextTest =function() {
  44. testNum++;
  45. switch (testNum) {
  46. case 1: setTimeout(step1, 0); break;
  47. case 2: setTimeout(step2, 0); break;
  48. case 3: setTimeout(step3, 0); break;
  49. };
  50. }
  51. var step1 =function() {
  52. window.is(testWindow.location, gTallRedBoxURI, "Ensure red page loaded.");
  53. // Navigate down and up.
  54. is(testWindow.document.body.scrollTop, 0,
  55. "Page1: Ensure we scrollpane is at the top before we start scrolling.");
  56. testWindow.addEventListener("scroll", function () {
  57. testWindow.removeEventListener("scroll", arguments.callee, true);
  58. isnot(testWindow.document.body.scrollTop, 0,
  59. "Page1: Ensure we can scroll down.");
  60. SimpleTest.executeSoon(step1_2);
  61. }, true);
  62. sendKey('DOWN', testWindow);
  63. function step1_2() {
  64. testWindow.addEventListener("scroll", function () {
  65. testWindow.removeEventListener("scroll", arguments.callee, true);
  66. is(testWindow.document.body.scrollTop, 0,
  67. "Page1: Ensure we can scroll up, back to the top.");
  68. // Nav to blue box page. This should fire step2.
  69. testWindow.location = gTallBlueBoxURI;
  70. }, true);
  71. sendKey('UP', testWindow);
  72. }
  73. }
  74. var step2 =function() {
  75. window.is(testWindow.location, gTallBlueBoxURI, "Ensure blue page loaded.");
  76. // Scroll around a bit.
  77. is(testWindow.document.body.scrollTop, 0,
  78. "Page2: Ensure we scrollpane is at the top before we start scrolling.");
  79. var count = 0;
  80. testWindow.addEventListener("scroll", function () {
  81. if (++count < 4) {
  82. SimpleTest.executeSoon(function () { sendKey('DOWN', testWindow); });
  83. } else {
  84. testWindow.removeEventListener("scroll", arguments.callee, true);
  85. isnot(testWindow.document.body.scrollTop, 0,
  86. "Page2: Ensure we could scroll.");
  87. // Navigate backwards. This should fire step3.
  88. testWindow.history.back();
  89. }
  90. }, true);
  91. sendKey('DOWN', testWindow);
  92. }
  93. var step3 =function() {
  94. window.is(testWindow.location, gTallRedBoxURI,
  95. "Ensure red page restored from history.");
  96. // Check we can still scroll with the keys.
  97. is(testWindow.document.body.scrollTop, 0,
  98. "Page1Again: Ensure scroll pane at top before we scroll.");
  99. testWindow.addEventListener("scroll", function () {
  100. testWindow.removeEventListener("scroll", arguments.callee, true);
  101. isnot(testWindow.document.body.scrollTop, 0,
  102. "Page2Again: Ensure we can still scroll.");
  103. testWindow.close();
  104. SpecialPowers.clearUserPref(smoothScrollPref);
  105. window.SimpleTest.finish();
  106. }, true);
  107. sendKey('DOWN', testWindow);
  108. }
  109. SimpleTest.waitForExplicitFinish();
  110. //]]>
  111. </script>
  112. </pre>
  113. </body>
  114. </html>