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