OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>ScrollState consumeDelta</title> | 4 <title>ScrollState consumeDelta</title> |
5 <script src="../../../resources/testharness.js"></script> | 5 <script src="../../../resources/testharness.js"></script> |
6 <script src="../../../resources/testharnessreport.js"></script> | 6 <script src="../../../resources/testharnessreport.js"></script> |
7 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <script> | 9 <script> |
10 | 10 |
| 11 if (!window.internals || !window.internals.runtimeFlags.scrollCustomizationEnabl
ed) { |
| 12 console.log("These tests only work with window.internals exposed, " + |
| 13 "and require scroll customization."); |
| 14 done(); |
| 15 } |
| 16 |
11 function deltaShouldBe(scrollState, x, y, testName) { | 17 function deltaShouldBe(scrollState, x, y, testName) { |
12 test(function() { | 18 test(function() { |
13 assert_equals(scrollState.deltaX, x); | 19 assert_equals(scrollState.deltaX, x); |
14 assert_equals(scrollState.deltaY, y); | 20 assert_equals(scrollState.deltaY, y); |
15 }, testName); | 21 }, testName); |
16 } | 22 } |
17 | 23 |
18 test(function() { | 24 var scrollState = new ScrollState(10, -20); |
19 assert_true('ScrollState' in window, "'ScrollState' in window"); | 25 deltaShouldBe(scrollState, 10, -20, "Unconsumed deltas"); |
20 }, "These tests only work with scroll customization enabled."); | 26 scrollState.consumeDelta(2, -3); |
21 | 27 deltaShouldBe(scrollState, 8, -17, "Partially consumed deltas"); |
22 if ('ScrollState' in window) { | 28 scrollState.consumeDelta(8, -17); |
23 var scrollState = new ScrollState(10, -20); | 29 deltaShouldBe(scrollState, 0, 0, "Fully consumed deltas"); |
24 deltaShouldBe(scrollState, 10, -20, "Unconsumed deltas"); | |
25 scrollState.consumeDelta(2, -3); | |
26 deltaShouldBe(scrollState, 8, -17, "Partially consumed deltas"); | |
27 scrollState.consumeDelta(8, -17); | |
28 deltaShouldBe(scrollState, 0, 0, "Fully consumed deltas"); | |
29 } | |
30 </script> | 30 </script> |
31 </body> | 31 </body> |
32 </html> | 32 </html> |
OLD | NEW |