Index: LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-distribute-to-scroll-chain-descendant.html |
diff --git a/LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-distribute-to-scroll-chain-descendant.html b/LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-distribute-to-scroll-chain-descendant.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e2cbe609338750c6b3926bfbb8eddca7e05163ee |
--- /dev/null |
+++ b/LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-distribute-to-scroll-chain-descendant.html |
@@ -0,0 +1,54 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<meta charset="utf-8"> |
+<title>ScrollState constructor behaves correctly</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(); |
+} |
+ |
+var elementCount = 10; |
+var remainingNumberOfTimesToBeCalled = elementCount; |
+ |
+var distributeScroll = function(scrollState) { |
+ this.calledOrder = elementCount - remainingNumberOfTimesToBeCalled; |
+ remainingNumberOfTimesToBeCalled--; |
+ scrollState.distributeToScrollChainDescendant(); |
+} |
+ |
+var elements = []; |
+for (var i = 0; i < elementCount; ++i) { |
+ var element = document.createElement("div"); |
+ element.creationOrder = i; |
+ element.distributeScroll = distributeScroll; |
+ elements.push(element); |
+} |
+ |
+test(function() { |
+ var scrollState = new ScrollState(100, 0, 0, 0, 0, false, false); |
+ window.internals.setScrollChain(scrollState, elements); |
+ scrollState.distributeToScrollChainDescendant(); |
+ assert_equals(0, remainingNumberOfTimesToBeCalled); |
+ for (var i = 0; i < elementCount; ++i) |
+ assert_equals(elements[i].creationOrder, elements[i].calledOrder); |
+}, "distributeToScrollChainDescendant propagates correctly."); |
+ |
+test(function() { |
+ var scrollState = new ScrollState(100, 0, 0, 0, 0, false, false); |
+ window.internals.setScrollChain(scrollState, []); |
+ assert_equals(0, remainingNumberOfTimesToBeCalled); |
+ scrollState.distributeToScrollChainDescendant(); |
+ assert_equals(0, remainingNumberOfTimesToBeCalled); |
+}, "distributeToScrollChainDescendant with empty scroll chain does nothing."); |
+ |
+</script> |
+</body> |
+</html> |