dom/events/test/test_bug607464.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/events/test/test_bug607464.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,101 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=607464
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 607464</title>
    1.11 +  <script type="application/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=607464">Mozilla Bug 607464</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 type="application/javascript;version=1.7">
    1.23 +
    1.24 +/**
    1.25 + * Test for Bug 607464:
    1.26 + * Pixel scrolling shouldn't scroll smoothly, even if general.smoothScroll is on.
    1.27 + **/
    1.28 +
    1.29 +function scrollDown15PxWithPixelScrolling(scrollbox) {
    1.30 +  var win = scrollbox.ownerDocument.defaultView;
    1.31 +  let event = {
    1.32 +    deltaMode: WheelEvent.DOM_DELTA_PIXEL,
    1.33 +    deltaY: 3.0,
    1.34 +    lineOrPageDeltaY: 1
    1.35 +  };
    1.36 +  // A pixel scroll with lineOrPageDeltaY.
    1.37 +  synthesizeWheel(scrollbox, 10, 10, event, win);
    1.38 +  // then 4 pixel scrolls without lineOrPageDeltaY.
    1.39 +  event.lineOrPageDeltaY = 0;
    1.40 +  for (let i = 0; i < 4; ++i) {
    1.41 +    synthesizeWheel(scrollbox, 10, 10, event, win);
    1.42 +  }
    1.43 +
    1.44 +  // Note: the line scroll shouldn't have any effect because it has
    1.45 +  // hasPixels = true set on it. We send it to emulate normal
    1.46 +  // behavior.
    1.47 +}
    1.48 +
    1.49 +function runTest() {
    1.50 +  var win = open('data:text/html,<!DOCTYPE html>\n' +
    1.51 +    '<div id="scrollbox" style="height: 100px; overflow: auto;">' +
    1.52 +    '  <div style="height: 1000px;"></div>' +
    1.53 +    '</div>', '_blank', 'width=300,height=300');
    1.54 +  SimpleTest.waitForFocus(function () {
    1.55 +    var scrollbox = win.document.getElementById("scrollbox");
    1.56 +    let scrollTopBefore = scrollbox.scrollTop;
    1.57 +
    1.58 +    scrollDown15PxWithPixelScrolling(scrollbox);
    1.59 +
    1.60 +    // wait for the next refresh driver run
    1.61 +    window.mozRequestAnimationFrame(function() {
    1.62 +      // actually, wait for the next one before checking results, since
    1.63 +      // scrolling might not be flushed until after this code has run
    1.64 +      window.mozRequestAnimationFrame(function() {
    1.65 +        is(scrollbox.scrollTop, scrollTopBefore + 15,
    1.66 +           "Pixel scrolling should have finished after one refresh driver iteration. " +
    1.67 +           "We shouldn't be scrolling smoothly, even though the pref is set.");
    1.68 +        win.close();
    1.69 +        clearPrefs();
    1.70 +        SimpleTest.finish();
    1.71 +      });
    1.72 +    });
    1.73 +  }, win);
    1.74 +}
    1.75 +
    1.76 +function initPrefs()
    1.77 +{
    1.78 +  // Disables the app level scroll acceleration
    1.79 +  SpecialPowers.setIntPref("mousewheel.acceleration.start", -1);
    1.80 +  SpecialPowers.setBoolPref("mousewheel.system_scroll_override_on_root_content.enabled", false);
    1.81 +
    1.82 +  // Enables smooth scrolling
    1.83 +  SpecialPowers.setBoolPref("general.smoothScroll", true);
    1.84 +}
    1.85 +
    1.86 +function clearPrefs()
    1.87 +{
    1.88 +  SpecialPowers.clearUserPref("mousewheel.acceleration.start");
    1.89 +  SpecialPowers.clearUserPref("mousewheel.system_scroll_override_on_root_content.enabled");
    1.90 +  SpecialPowers.clearUserPref("general.smoothScroll");
    1.91 +}
    1.92 +
    1.93 +window.onload = function () {
    1.94 +  initPrefs();
    1.95 +  SimpleTest.executeSoon(runTest);
    1.96 +}
    1.97 +
    1.98 +SimpleTest.waitForExplicitFinish();
    1.99 +
   1.100 +</script>
   1.101 +</pre>
   1.102 +
   1.103 +</body>
   1.104 +</html>

mercurial