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>
12 assert_true('ScrollState' in window
, "'ScrollState' in window");
13 }, "These tests only work with scroll customization enabled.");
15 function testConsumingDelta(dx
, dy
, consume_x
, consume_y
, testName
, expectedError
) {
17 var scrollState
= new ScrollState(dx
, dy
);
18 assert_throws('InvalidModificationError', function() {
19 scrollState
.consumeDelta(consume_x
, consume_y
);
21 assert_equals(scrollState
.deltaX
, dx
);
22 assert_equals(scrollState
.deltaY
, dy
);
26 if ('ScrollState' in window
) {
27 // Consume from an event with a delta of (5, 5).
28 testConsumingDelta(5, 5, 6, 4, "Overconsumed X");
29 testConsumingDelta(5, 5, 4, 6, "Overconsumed Y");
30 testConsumingDelta(5, 5, -1, 4, "Can't increase X delta");
31 testConsumingDelta(5, 5, 4, -1, "Can't increase Y delta");
33 // Consume from an event with a delta of (-5, -5).
34 testConsumingDelta(-5, -5, -6, -4, "Overconsumed X with negative delta");
35 testConsumingDelta(-5, -5, -4, -6, "Overconsumed Y with negative delta");
36 testConsumingDelta(-5, -5, 1, -4, "Can't increase X delta magnitude");
37 testConsumingDelta(-5, -5, -4, 1, "Can't increase Y delta magnitude");