OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
2 <script src="../../../resources/js-test.js"></script> | 2 <script src="../../../resources/js-test.js"></script> |
3 <style> | 3 <style type="text/css"> |
4 body { | 4 body { |
5 height: 2000px; | 5 height: 2000px; |
6 width: 2000px; | 6 width: 2000px; |
7 } | 7 } |
8 </style> | 8 </style> |
9 | 9 |
10 <script> | 10 <script> |
11 window.jsTestIsAsync = true; | 11 window.jsTestIsAsync = true; |
| 12 var dpr = window.devicePixelRatio; |
12 | 13 |
13 description("This test ensures that consecutive mouse wheel ticks scroll\ | 14 description("This test ensures that mouse wheel ticks scrolls the right numb
er of pixels in high dpi mode."); |
14 to the right offset. The main purpose of this test is to ensure that\ | |
15 smooth scrolling on the compositor works as intended (tested via\ | |
16 virtual suite virtual/threaded/)."); | |
17 | 15 |
18 function testDiagonalScroll() { | 16 function testDiagonalScroll() { |
19 // Reset | 17 // Reset |
20 document.scrollingElement.scrollTop = 0; | 18 document.scrollingElement.scrollTop = 0; |
21 document.scrollingElement.scrollLeft = 0; | 19 document.scrollingElement.scrollLeft = 0; |
22 | 20 |
23 eventSender.mouseMoveTo(20, 20); | 21 eventSender.mouseMoveTo(20, 20); |
24 // Scroll 3 ticks diagonally. | 22 // 1 tick should move 40px. |
25 eventSender.mouseScrollBy(-3, -3); | 23 eventSender.mouseScrollBy(-2 * dpr, -2 * dpr); |
26 // Undo 2 ticks in each direction. | 24 |
27 eventSender.mouseScrollBy(2, 2); | 25 shouldBecomeEqual("document.scrollingElement.scrollTop == 80 && " + |
28 // 40px per tick. | 26 "document.scrollingElement.scrollLeft == 80", "true", finishJSTest); |
29 shouldBecomeEqual("document.scrollingElement.scrollTop == 40 && " + | |
30 "document.scrollingElement.scrollLeft == 40", "true", finishJSTest); | |
31 } | 27 } |
32 | 28 |
33 function runTest() { | 29 function runTest() { |
34 if (!window.eventSender || !window.internals) { | 30 if (!window.eventSender || !window.internals) { |
| 31 debug("This test requires window.eventSender and window.internals."); |
35 finishJSTest(); | 32 finishJSTest(); |
36 return; | 33 return; |
37 } | 34 } |
38 | 35 |
39 // Turn on smooth scrolling. | 36 // Turn on smooth scrolling. |
40 internals.settings.setScrollAnimatorEnabled(true); | 37 internals.settings.setScrollAnimatorEnabled(true); |
41 | 38 |
42 eventSender.mouseMoveTo(20, 20); | 39 eventSender.mouseMoveTo(20, 20); |
43 // Scroll down 3 ticks. | 40 // 1 tick should move 40px. |
44 eventSender.mouseScrollBy(0, -1); | 41 eventSender.mouseScrollBy(-dpr, -dpr); |
45 eventSender.mouseScrollBy(0, -2); | |
46 // Scroll right 3 ticks. | |
47 eventSender.mouseScrollBy(-1, 0); | |
48 eventSender.mouseScrollBy(-2, 0); | |
49 // Undo 1 tick in each direction. | |
50 eventSender.mouseScrollBy(0, 1); | |
51 eventSender.mouseScrollBy(1, 0); | |
52 | 42 |
53 // 40px per tick. | 43 // 40px per tick. |
54 shouldBecomeEqual("document.scrollingElement.scrollTop == 80 && " + | 44 shouldBecomeEqual("document.scrollingElement.scrollTop == 40 && " + |
55 "document.scrollingElement.scrollLeft == 80", "true", testDiagonalScro
ll); | 45 "document.scrollingElement.scrollLeft == 40", "true", testDiagonalScro
ll); |
56 } | 46 } |
57 </script> | 47 </script> |
58 | 48 |
59 <body onload="runTest()"></body> | 49 <body onload="runTest()"></body> |
OLD | NEW |