OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>ScrollState's consumeDelta method throws on invalid deltas</title> |
| 5 <script src="../../../resources/testharness.js"></script> |
| 6 <script src="../../../resources/testharnessreport.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <script> |
| 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 |
| 17 function testConsumingDelta(dx, dy, consume_x, consume_y, testName, expectedErro
r) { |
| 18 test(function() { |
| 19 var scrollState = new ScrollState(dx, dy); |
| 20 assert_throws('InvalidModificationError', function() { |
| 21 scrollState.consumeDelta(consume_x, consume_y); |
| 22 }); |
| 23 }, testName); |
| 24 } |
| 25 |
| 26 // Consume from an event with a delta of (5, 5). |
| 27 testConsumingDelta(5, 5, 6, 4, "Overconsumed X"); |
| 28 testConsumingDelta(5, 5, 4, 6, "Overconsumed Y"); |
| 29 testConsumingDelta(5, 5, -1, 4, "Can't increase X delta"); |
| 30 testConsumingDelta(5, 5, 4, -1, "Can't increase Y delta"); |
| 31 |
| 32 // Consume from an event with a delta of (-5, -5). |
| 33 testConsumingDelta(-5, -5, -6, -4, "Overconsumed X with negative delta"); |
| 34 testConsumingDelta(-5, -5, -4, -6, "Overconsumed Y with negative delta"); |
| 35 testConsumingDelta(-5, -5, 1, -4, "Can't increase X delta magnitude"); |
| 36 testConsumingDelta(-5, -5, -4, 1, "Can't increase Y delta magnitude"); |
| 37 </script> |
| 38 </body> |
| 39 </html> |
OLD | NEW |