tor-browser

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

test_bug607464.html (2517B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=607464
      5 -->
      6 <head>
      7  <title>Test for Bug 607464</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <script type="text/javascript" src="/tests/gfx/layers/apz/test/mochitest/apz_test_utils.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12 </head>
     13 <body>
     14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=607464">Mozilla Bug 607464</a>
     15 <p id="display"></p>
     16 <div id="content" style="display: none">
     17 
     18 </div>
     19 <pre id="test">
     20 <script type="application/javascript">
     21 
     22 /**
     23 * Test for Bug 607464:
     24 * Pixel scrolling shouldn't scroll smoothly, even if general.smoothScroll is on.
     25 */
     26 
     27 function scrollDown150PxWithPixelScrolling(scrollbox) {
     28  var win = scrollbox.ownerDocument.defaultView;
     29  let event = {
     30    deltaMode: WheelEvent.DOM_DELTA_PIXEL,
     31    deltaY: 30.0,
     32    lineOrPageDeltaY: 1
     33  };
     34  // A pixel scroll with lineOrPageDeltaY.
     35  synthesizeWheel(scrollbox, 10, 10, event, win);
     36  // then 4 pixel scrolls without lineOrPageDeltaY.
     37  event.lineOrPageDeltaY = 0;
     38  for (let i = 0; i < 4; ++i) {
     39    synthesizeWheel(scrollbox, 10, 10, event, win);
     40  }
     41 
     42  // Note: the line scroll shouldn't have any effect because it has
     43  // hasPixels = true set on it. We send it to emulate normal
     44  // behavior.
     45 }
     46 
     47 function runTest() {
     48  var win = open('bug607464.html', '_blank', 'width=300,height=300');
     49  SimpleTest.waitForFocus(function () {
     50    var scrollbox = win.document.getElementById("scrollbox");
     51    let scrollTopBefore = scrollbox.scrollTop;
     52 
     53    win.addEventListener("scroll", function(e) {
     54      is(scrollbox.scrollTop % 30, 0,
     55         "Pixel scrolling should happen instantly, not smoothly. The " +
     56         "scroll position " + scrollbox.scrollTop + " in this sequence of wheel " +
     57         "events should be a multiple of 30.");
     58      if (scrollbox.scrollTop == 150) {
     59        win.close();
     60        SimpleTest.finish();
     61      }
     62    }, true);
     63 
     64    promiseOnlyApzControllerFlushed(win).then(function() {
     65      scrollDown150PxWithPixelScrolling(scrollbox);
     66    });
     67  }, win);
     68 }
     69 
     70 window.onload = function() {
     71  SpecialPowers.pushPrefEnv({
     72    "set":[["general.smoothScroll", true],
     73           ["mousewheel.acceleration.start", -1],
     74           ["mousewheel.system_scroll_override.enabled", false]]}, runTest);
     75 }
     76 
     77 SimpleTest.waitForExplicitFinish();
     78 SimpleTest.testInChaosMode();
     79 
     80 </script>
     81 </pre>
     82 
     83 </body>
     84 </html>