docshell/test/navigation/test_bug430723.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/navigation/test_bug430723.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,140 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=430723
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 430723</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=430723">Mozilla Bug 430723</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content" style="display: none">
    1.19 +  
    1.20 +</div>
    1.21 +<pre id="test">
    1.22 +<script class="testbody" type="text/javascript">
    1.23 +//<![CDATA[
    1.24 +
    1.25 +/** Test for Bug 430723 **/
    1.26 +
    1.27 +var gTallRedBoxURI = "data:text/html;charset=utf-8;base64,PGh0bWw%2BPGhlYWQ%2BPHNjcmlwdD53aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcigncGFnZXNob3cnLCBmdW5jdGlvbigpe29wZW5lci5uZXh0VGVzdCgpO30sIGZhbHNlKTs8L3NjcmlwdD48L2hlYWQ%2BPGJvZHk%2BPGRpdiBzdHlsZT0icG9zaXRpb246YWJzb2x1dGU7IGxlZnQ6MHB4OyB0b3A6MHB4OyB3aWR0aDo1MCU7IGhlaWdodDoxNTAlOyBiYWNrZ3JvdW5kLWNvbG9yOnJlZCI%2BPHA%2BVGhpcyBpcyBhIHZlcnkgdGFsbCByZWQgYm94LjwvcD48L2Rpdj48L2JvZHk%2BPC9odG1sPg%3D%3D";
    1.28 +// <html><head>
    1.29 +// < script > window.addEventListener("pageshow", function(){opener.nextTest();}, false); < /script > 
    1.30 +// </head><body>
    1.31 +// <div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:red">
    1.32 +// <p>This is a very tall red box.</p>
    1.33 +// </div></body></html>
    1.34 +
    1.35 +var gTallBlueBoxURI = "data:text/html;charset=utf-8;base64,PGh0bWw%2BPGhlYWQ%2BPHNjcmlwdD53aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcigncGFnZXNob3cnLCBmdW5jdGlvbigpe29wZW5lci5uZXh0VGVzdCgpO30sIGZhbHNlKTs8L3NjcmlwdD48L2hlYWQ%2BPGJvZHk%2BPGRpdiBzdHlsZT0icG9zaXRpb246YWJzb2x1dGU7IGxlZnQ6MHB4OyB0b3A6MHB4OyB3aWR0aDo1MCU7IGhlaWdodDoxNTAlOyBiYWNrZ3JvdW5kLWNvbG9yOmJsdWUiPjxwPlRoaXMgaXMgYSB2ZXJ5IHRhbGwgYmx1ZSBib3guPC9wPjwvZGl2PjwvYm9keT48L2h0bWw%2B";
    1.36 +// <html><head>
    1.37 +// < script > window.addEventListener("pageshow", function(){opener.nextTest();}, false); < /script > 
    1.38 +// </head><body>
    1.39 +// <div style="position:absolute; left:0px; top:0px; width:50%; height:150%; background-color:blue">
    1.40 +// <p>This is a very tall blue box.</p>
    1.41 +// </div></body></html>
    1.42 +
    1.43 +
    1.44 +window.onload = runTest;
    1.45 +
    1.46 +var testWindow;
    1.47 +var testNum = 0;
    1.48 +
    1.49 +var smoothScrollPref = "general.smoothScroll";
    1.50 +function runTest() {
    1.51 +  SpecialPowers.setBoolPref(smoothScrollPref, false);
    1.52 +  testWindow = window.open(gTallRedBoxURI, "testWindow", "width=300,height=300,location=yes,scrollbars=yes");
    1.53 +}
    1.54 +
    1.55 +var nextTest =function() {
    1.56 +  testNum++;
    1.57 +  switch (testNum) {
    1.58 +    case 1: setTimeout(step1, 0); break;
    1.59 +    case 2: setTimeout(step2, 0); break;
    1.60 +    case 3: setTimeout(step3, 0); break;
    1.61 +  };
    1.62 +}
    1.63 +
    1.64 +var step1 =function() {
    1.65 +  window.is(testWindow.location, gTallRedBoxURI, "Ensure red page loaded.");
    1.66 +  
    1.67 +  // Navigate down and up.
    1.68 +  is(testWindow.document.body.scrollTop, 0,
    1.69 +     "Page1: Ensure the scrollpane is at the top before we start scrolling.");
    1.70 +  testWindow.addEventListener("scroll", function () {
    1.71 +    testWindow.removeEventListener("scroll", arguments.callee, true);
    1.72 +    isnot(testWindow.document.body.scrollTop, 0,
    1.73 +          "Page1: Ensure we can scroll down.");
    1.74 +    SimpleTest.executeSoon(step1_2);
    1.75 +  }, true);
    1.76 +  sendKey('DOWN', testWindow);
    1.77 +
    1.78 +  function step1_2() {
    1.79 +    testWindow.addEventListener("scroll", function () {
    1.80 +      testWindow.removeEventListener("scroll", arguments.callee, true);
    1.81 +      is(testWindow.document.body.scrollTop, 0,
    1.82 +         "Page1: Ensure we can scroll up, back to the top.");  
    1.83 +
    1.84 +      // Nav to blue box page. This should fire step2.
    1.85 +      testWindow.location = gTallBlueBoxURI;
    1.86 +    }, true);
    1.87 +    sendKey('UP', testWindow);
    1.88 +  }
    1.89 +}
    1.90 +
    1.91 +
    1.92 +var step2 =function() {    
    1.93 +  window.is(testWindow.location, gTallBlueBoxURI, "Ensure blue page loaded.");
    1.94 +
    1.95 +  // Scroll around a bit.
    1.96 +  is(testWindow.document.body.scrollTop, 0,
    1.97 +     "Page2: Ensure the scrollpane is at the top before we start scrolling.");
    1.98 +
    1.99 +  var count = 0;
   1.100 +  testWindow.addEventListener("scroll", function () {
   1.101 +    if (++count < 2) {
   1.102 +      SimpleTest.executeSoon(function () { sendKey('DOWN', testWindow); });
   1.103 +    } else {
   1.104 +      testWindow.removeEventListener("scroll", arguments.callee, true);
   1.105 +
   1.106 +      isnot(testWindow.document.body.scrollTop, 0,
   1.107 +            "Page2: Ensure we could scroll.");
   1.108 +
   1.109 +      // Navigate backwards. This should fire step3.
   1.110 +      testWindow.history.back();
   1.111 +    }
   1.112 +  }, true);
   1.113 +  sendKey('DOWN', testWindow);
   1.114 +}
   1.115 +
   1.116 +var step3 =function() {
   1.117 +  window.is(testWindow.location, gTallRedBoxURI,
   1.118 +            "Ensure red page restored from history.");
   1.119 +
   1.120 +  // Check we can still scroll with the keys.
   1.121 +  is(testWindow.document.body.scrollTop, 0,
   1.122 +     "Page1Again: Ensure scroll pane at top before we scroll.");  
   1.123 +  testWindow.addEventListener("scroll", function () {
   1.124 +    testWindow.removeEventListener("scroll", arguments.callee, true);
   1.125 +
   1.126 +    isnot(testWindow.document.body.scrollTop, 0,
   1.127 +          "Page2Again: Ensure we can still scroll.");  
   1.128 +
   1.129 +    testWindow.close();
   1.130 +    SpecialPowers.clearUserPref(smoothScrollPref);
   1.131 +    window.SimpleTest.finish();
   1.132 +  }, true);
   1.133 +  sendKey('DOWN', testWindow);
   1.134 +}
   1.135 +
   1.136 +SimpleTest.waitForExplicitFinish();
   1.137 +
   1.138 +//]]>
   1.139 +</script>
   1.140 +</pre>
   1.141 +</body>
   1.142 +</html>
   1.143 +

mercurial