dom/events/test/test_bug422132.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=422132
     5 -->
     6 <head>
     7   <title>Test for Bug 422132</title>
     8   <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
     9   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.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=422132">Mozilla Bug 422132</a>
    15 <p id="display"></p>
    16 <div id="target" style="font-size: 0; width: 200px; height: 200px; overflow: auto;">
    17   <div style="width: 1000px; height: 1000px;"></div>
    18 </div>
    19 <div id="content" style="display: none">
    21 </div>
    22 <pre id="test">
    23 <script class="testbody" type="text/javascript">
    25 /** Test for Bug 422132 **/
    27 SimpleTest.waitForExplicitFinish();
    28 SimpleTest.waitForFocus(runTests, window);
    30 function hitEventLoop(aFunc, aTimes)
    31 {
    32   if (--aTimes) {
    33     setTimeout(hitEventLoop, 0, aFunc, aTimes);
    34   } else {
    35     setTimeout(aFunc, 20);
    36   }
    37 }
    39 function runTests()
    40 {
    41   SpecialPowers.setBoolPref("general.smoothScroll", false);
    42   SpecialPowers.setIntPref("mousewheel.min_line_scroll_amount", 1);
    43   SpecialPowers.setIntPref("mousewheel.transaction.timeout", 100000);
    45   var target = document.getElementById("target");
    47   var scrollLeft = target.scrollLeft;
    48   var scrollTop = target.scrollTop;
    49   synthesizeWheel(target, 10, 10,
    50     { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
    51       deltaX: 0.5, deltaY: 0.5, lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 });
    52   hitEventLoop(function () {
    53     is(target.scrollLeft, scrollLeft, "scrolled to right by 0.5px delta value");
    54     is(target.scrollTop, scrollTop, "scrolled to bottom by 0.5px delta value");
    55     scrollLeft = target.scrollLeft;
    56     scrollTop = target.scrollTop;
    57     synthesizeWheel(target, 10, 10,
    58       { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
    59         deltaX: 0.5, deltaY: 0.5, lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 });
    60     hitEventLoop(function () {
    61       ok(target.scrollLeft > scrollLeft,
    62          "not scrolled to right by 0.5px delta value with pending 0.5px delta");
    63       ok(target.scrollTop > scrollTop,
    64          "not scrolled to bottom by 0.5px delta value with pending 0.5px delta");
    65       scrollLeft = target.scrollLeft;
    66       scrollTop = target.scrollTop;
    67       synthesizeWheel(target, 10, 10,
    68         { deltaMode: WheelEvent.DOM_DELTA_LINE,
    69           deltaX: 0.5, deltaY: 0.5, lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 });
    70       hitEventLoop(function () {
    71         is(target.scrollLeft, scrollLeft, "scrolled to right by 0.5 line delta value");
    72         is(target.scrollTop, scrollTop, "scrolled to bottom by 0.5 line delta value");
    73         scrollLeft = target.scrollLeft;
    74         scrollTop = target.scrollTop;
    75         synthesizeWheel(target, 10, 10,
    76           { deltaMode: WheelEvent.DOM_DELTA_LINE,
    77             deltaX: 0.5, deltaY: 0.5, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 });
    78         hitEventLoop(function () {
    79           ok(target.scrollLeft > scrollLeft,
    80              "not scrolled to right by 0.5 line delta value with pending 0.5 line delta");
    81           ok(target.scrollTop > scrollTop,
    82              "not scrolled to bottom by 0.5 line delta value with pending 0.5 line delta");
    83           SpecialPowers.clearUserPref("general.smoothScroll");
    84           SpecialPowers.clearUserPref("mousewheel.min_line_scroll_amount");
    85           SpecialPowers.clearUserPref("mousewheel.transaction.timeout");
    86           SimpleTest.finish();
    87         }, 20);
    88       }, 20);
    89     }, 20);
    90   }, 20);
    91 }
    93 </script>
    94 </pre>
    95 </body>
    96 </html>

mercurial