Index: LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-consume-deltas-throw.html |
diff --git a/LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-consume-deltas-throw.html b/LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-consume-deltas-throw.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7f44f5849510def34ee6cfc70c79d469e0744ba5 |
--- /dev/null |
+++ b/LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-consume-deltas-throw.html |
@@ -0,0 +1,39 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<title>ScrollState's consumeDelta method throws on invalid deltas</title> |
+<script src="../../../resources/testharness.js"></script> |
+<script src="../../../resources/testharnessreport.js"></script> |
+</head> |
+<body> |
+<script> |
+ |
+if (!window.internals || !window.internals.runtimeFlags.scrollCustomizationEnabled) { |
+ console.log("These tests only work with window.internals exposed, " + |
+ "and require scroll customization."); |
+ done(); |
+} |
+ |
+function testConsumingDelta(dx, dy, consume_x, consume_y, testName, expectedError) { |
+ test(function() { |
+ var scrollState = new ScrollState(dx, dy); |
+ assert_throws('InvalidModificationError', function() { |
+ scrollState.consumeDelta(consume_x, consume_y); |
+ }); |
+ }, testName); |
+} |
+ |
+// Consume from an event with a delta of (5, 5). |
+testConsumingDelta(5, 5, 6, 4, "Overconsumed X"); |
+testConsumingDelta(5, 5, 4, 6, "Overconsumed Y"); |
+testConsumingDelta(5, 5, -1, 4, "Can't increase X delta"); |
+testConsumingDelta(5, 5, 4, -1, "Can't increase Y delta"); |
+ |
+// Consume from an event with a delta of (-5, -5). |
+testConsumingDelta(-5, -5, -6, -4, "Overconsumed X with negative delta"); |
+testConsumingDelta(-5, -5, -4, -6, "Overconsumed Y with negative delta"); |
+testConsumingDelta(-5, -5, 1, -4, "Can't increase X delta magnitude"); |
+testConsumingDelta(-5, -5, -4, 1, "Can't increase Y delta magnitude"); |
+</script> |
+</body> |
+</html> |