tor-browser

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

test_spacetopagedown.html (2083B)


      1 <html>
      2 <head>
      3  <meta charset="utf-8">
      4  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
      5  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
      6  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
      7  <script type="application/javascript">
      8 
      9 SimpleTest.waitForExplicitFinish();
     10 
     11 
     12 var windowUtils = SpecialPowers.getDOMWindowUtils(window);
     13 
     14 function pressKey(isShift)
     15 {
     16  return new Promise(resolve => {
     17    synthesizeKey(" ", { shiftKey: isShift });
     18    windowUtils.advanceTimeAndRefresh(100);
     19    SimpleTest.executeSoon(resolve);
     20  });
     21 }
     22 
     23 function initTest()
     24 {
     25  SpecialPowers.pushPrefEnv({"set":[["general.smoothScroll", false]]}, runTest);
     26 }
     27 
     28 function runTest()
     29 {
     30  (async function() {
     31    await pressKey(false);
     32 
     33    ok(window.scrollY > 0, "Space with no focus" + window.scrollY);
     34    await pressKey(true);
     35    is(window.scrollY, 0, "Shift+Space with no focus");
     36 
     37    let checkbox = document.getElementById("checkbox");
     38    checkbox.focus();
     39    await pressKey(false);
     40 
     41    is(window.scrollY, 0, "Space with checkbox focused");
     42    ok(checkbox.checked, "Space with checkbox focused, checked");
     43    await pressKey(true);
     44    is(window.scrollY, 0, "Shift+Space with checkbox focused");
     45    ok(!checkbox.checked, "Space with checkbox focused, unchecked");
     46 
     47    let input = document.getElementById("input");
     48    input.focus();
     49    await pressKey(false);
     50    is(window.scrollY, 0, "Space with input focused");
     51    is(input.value, " ", "Space with input focused, value");
     52    await pressKey(true);
     53    is(window.scrollY, 0, "Shift+Space with input focused");
     54    is(input.value, "  ", "Space with input focused, value");
     55 
     56    windowUtils.restoreNormalRefresh();
     57    SimpleTest.finish();
     58  })();
     59 }
     60 
     61  </script>
     62 </head>
     63 <body onload="SimpleTest.waitForFocus(initTest)">
     64 
     65 <input id="checkbox" type="checkbox">Checkbox
     66 <input id="input">
     67 <p style="height: 4000px">Text</p>
     68 
     69 <p id="display"></p>
     70 <div id="content" style="display: none">
     71 </div>
     72 <pre id="test">
     73 </pre>
     74 </body>
     75 </html>