dom/events/test/test_bug607464.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=607464
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 607464</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11 </head>
michael@0 12 <body>
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=607464">Mozilla Bug 607464</a>
michael@0 14 <p id="display"></p>
michael@0 15 <div id="content" style="display: none">
michael@0 16
michael@0 17 </div>
michael@0 18 <pre id="test">
michael@0 19 <script type="application/javascript;version=1.7">
michael@0 20
michael@0 21 /**
michael@0 22 * Test for Bug 607464:
michael@0 23 * Pixel scrolling shouldn't scroll smoothly, even if general.smoothScroll is on.
michael@0 24 **/
michael@0 25
michael@0 26 function scrollDown15PxWithPixelScrolling(scrollbox) {
michael@0 27 var win = scrollbox.ownerDocument.defaultView;
michael@0 28 let event = {
michael@0 29 deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 30 deltaY: 3.0,
michael@0 31 lineOrPageDeltaY: 1
michael@0 32 };
michael@0 33 // A pixel scroll with lineOrPageDeltaY.
michael@0 34 synthesizeWheel(scrollbox, 10, 10, event, win);
michael@0 35 // then 4 pixel scrolls without lineOrPageDeltaY.
michael@0 36 event.lineOrPageDeltaY = 0;
michael@0 37 for (let i = 0; i < 4; ++i) {
michael@0 38 synthesizeWheel(scrollbox, 10, 10, event, win);
michael@0 39 }
michael@0 40
michael@0 41 // Note: the line scroll shouldn't have any effect because it has
michael@0 42 // hasPixels = true set on it. We send it to emulate normal
michael@0 43 // behavior.
michael@0 44 }
michael@0 45
michael@0 46 function runTest() {
michael@0 47 var win = open('data:text/html,<!DOCTYPE html>\n' +
michael@0 48 '<div id="scrollbox" style="height: 100px; overflow: auto;">' +
michael@0 49 ' <div style="height: 1000px;"></div>' +
michael@0 50 '</div>', '_blank', 'width=300,height=300');
michael@0 51 SimpleTest.waitForFocus(function () {
michael@0 52 var scrollbox = win.document.getElementById("scrollbox");
michael@0 53 let scrollTopBefore = scrollbox.scrollTop;
michael@0 54
michael@0 55 scrollDown15PxWithPixelScrolling(scrollbox);
michael@0 56
michael@0 57 // wait for the next refresh driver run
michael@0 58 window.mozRequestAnimationFrame(function() {
michael@0 59 // actually, wait for the next one before checking results, since
michael@0 60 // scrolling might not be flushed until after this code has run
michael@0 61 window.mozRequestAnimationFrame(function() {
michael@0 62 is(scrollbox.scrollTop, scrollTopBefore + 15,
michael@0 63 "Pixel scrolling should have finished after one refresh driver iteration. " +
michael@0 64 "We shouldn't be scrolling smoothly, even though the pref is set.");
michael@0 65 win.close();
michael@0 66 clearPrefs();
michael@0 67 SimpleTest.finish();
michael@0 68 });
michael@0 69 });
michael@0 70 }, win);
michael@0 71 }
michael@0 72
michael@0 73 function initPrefs()
michael@0 74 {
michael@0 75 // Disables the app level scroll acceleration
michael@0 76 SpecialPowers.setIntPref("mousewheel.acceleration.start", -1);
michael@0 77 SpecialPowers.setBoolPref("mousewheel.system_scroll_override_on_root_content.enabled", false);
michael@0 78
michael@0 79 // Enables smooth scrolling
michael@0 80 SpecialPowers.setBoolPref("general.smoothScroll", true);
michael@0 81 }
michael@0 82
michael@0 83 function clearPrefs()
michael@0 84 {
michael@0 85 SpecialPowers.clearUserPref("mousewheel.acceleration.start");
michael@0 86 SpecialPowers.clearUserPref("mousewheel.system_scroll_override_on_root_content.enabled");
michael@0 87 SpecialPowers.clearUserPref("general.smoothScroll");
michael@0 88 }
michael@0 89
michael@0 90 window.onload = function () {
michael@0 91 initPrefs();
michael@0 92 SimpleTest.executeSoon(runTest);
michael@0 93 }
michael@0 94
michael@0 95 SimpleTest.waitForExplicitFinish();
michael@0 96
michael@0 97 </script>
michael@0 98 </pre>
michael@0 99
michael@0 100 </body>
michael@0 101 </html>

mercurial