Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-distribute-to-scroll-chain-descendant.html

Issue 1209183004: Expose scroll customization for touch to JS (behind REF). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address skobes' nits. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c1f726fa7c3c5e14001104bc820c4945421c4b9e
--- /dev/null
+++ b/LayoutTests/fast/scroll-behavior/scroll-customization/scrollstate-distribute-to-scroll-chain-descendant.html
@@ -0,0 +1,55 @@
+<!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>
+test(function() {
+ assert_true('ScrollState' in window, "'ScrollState' in window");
+ // TODO(tdresser): Don't rely on window.internals. See crbug.com/483091 for details.
+ assert_true(window.internals !== null, "'ScrollState' in window");
+}, "These tests only work with scroll customization enabled.");
+
+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.setDistributeScroll(distributeScroll.bind(element), "disable-native-scroll");
+ elements.push(element);
+}
+
+if ('ScrollState' in window && window.internals) {
+ 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>

Powered by Google App Engine
This is Rietveld 408576698