tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug430723.html (3645B)


      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 src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script 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  
     17 </div>
     18 <pre id="test">
     19 <script class="testbody" type="text/javascript">
     20 // <![CDATA[
     21 
     22 /** Test for Bug 430723 */
     23 
     24 var BASE_URI = "http://mochi.test:8888/tests/docshell/test/navigation/";
     25 var gTallRedBoxURI = BASE_URI + "redbox_bug430723.html";
     26 var gTallBlueBoxURI = BASE_URI + "bluebox_bug430723.html";
     27 
     28 window.onload = runTest;
     29 
     30 var testWindow;
     31 var testNum = 0;
     32 
     33 var smoothScrollPref = "general.smoothScroll";
     34 function runTest() {
     35  SpecialPowers.pushPrefEnv({"set": [[smoothScrollPref, false]]}, function() {
     36    testWindow = window.open(gTallRedBoxURI, "testWindow", "width=300,height=300,location=yes,scrollbars=yes");
     37  });
     38 }
     39 
     40 var nextTest = function() {
     41  testNum++;
     42  switch (testNum) {
     43    case 1: setTimeout(step1, 0); break;
     44    case 2: setTimeout(step2, 0); break;
     45    case 3: setTimeout(step3, 0); break;
     46  }
     47 };
     48 
     49 var step1 = function() {
     50  window.is(String(testWindow.location), gTallRedBoxURI, "Ensure red page loaded.");
     51 
     52  // Navigate down and up.
     53  is(testWindow.document.body.scrollTop, 0,
     54     "Page1: Ensure the scrollpane is at the top before we start scrolling.");
     55  testWindow.addEventListener("scroll", function() {
     56    isnot(testWindow.document.body.scrollTop, 0,
     57          "Page1: Ensure we can scroll down.");
     58    SimpleTest.executeSoon(step1_2);
     59  }, {capture: true, once: true});
     60  sendKey("DOWN", testWindow);
     61 
     62  function step1_2() {
     63    testWindow.addEventListener("scroll", function() {
     64      is(testWindow.document.body.scrollTop, 0,
     65         "Page1: Ensure we can scroll up, back to the top.");
     66 
     67      // Nav to blue box page. This should fire step2.
     68      testWindow.location = gTallBlueBoxURI;
     69    }, {capture: true, once: true});
     70    sendKey("UP", testWindow);
     71  }
     72 };
     73 
     74 
     75 var step2 = function() {
     76  window.is(String(testWindow.location), gTallBlueBoxURI, "Ensure blue page loaded.");
     77 
     78  // Scroll around a bit.
     79  is(testWindow.document.body.scrollTop, 0,
     80     "Page2: Ensure the scrollpane is at the top before we start scrolling.");
     81 
     82  var scrollTest = function() {
     83    if (++count < 2) {
     84      SimpleTest.executeSoon(function() { sendKey("DOWN", testWindow); });
     85    } else {
     86      testWindow.removeEventListener("scroll", scrollTest, true);
     87 
     88      isnot(testWindow.document.body.scrollTop, 0,
     89            "Page2: Ensure we could scroll.");
     90 
     91      // Navigate backwards. This should fire step3.
     92      testWindow.history.back();
     93    }
     94  };
     95 
     96  var count = 0;
     97  testWindow.addEventListener("scroll", scrollTest, true);
     98  sendKey("DOWN", testWindow);
     99 };
    100 
    101 var step3 = function() {
    102  window.is(String(testWindow.location), gTallRedBoxURI,
    103            "Ensure red page restored from history.");
    104 
    105  // Check we can still scroll with the keys.
    106  is(testWindow.document.body.scrollTop, 0,
    107     "Page1Again: Ensure scroll pane at top before we scroll.");
    108  testWindow.addEventListener("scroll", function() {
    109    isnot(testWindow.document.body.scrollTop, 0,
    110          "Page2Again: Ensure we can still scroll.");
    111 
    112    testWindow.close();
    113    window.SimpleTest.finish();
    114  }, {capture: true, once: true});
    115  sendKey("DOWN", testWindow);
    116 };
    117 
    118 SimpleTest.waitForExplicitFinish();
    119 
    120 // ]]>
    121 </script>
    122 </pre>
    123 </body>
    124 </html>