5 <title>ScrollState constructor behaves correctly
</title>
6 <script src=
"../../../resources/testharness.js"></script>
7 <script src=
"../../../resources/testharnessreport.js"></script>
12 assert_true('ScrollState' in window
, "'ScrollState' in window");
13 // TODO(tdresser): Don't rely on window.internals. See crbug.com/483091 for details.
14 assert_true(window
.internals
!== null, "'ScrollState' in window");
15 }, "These tests only work with scroll customization enabled.");
17 var elementCount
= 10;
18 var remainingNumberOfTimesToBeCalled
= elementCount
;
20 var distributeScroll = function(scrollState
) {
21 this.calledOrder
= elementCount
- remainingNumberOfTimesToBeCalled
;
22 remainingNumberOfTimesToBeCalled
--;
23 scrollState
.distributeToScrollChainDescendant();
27 for (var i
= 0; i
< elementCount
; ++i
) {
28 var element
= document
.createElement("div");
29 element
.creationOrder
= i
;
30 element
.setDistributeScroll(distributeScroll
.bind(element
), "disable-native-scroll");
31 elements
.push(element
);
34 if ('ScrollState' in window
&& window
.internals
) {
36 var scrollState
= new ScrollState(100, 0, 0, 0, 0, false, false);
37 window
.internals
.setScrollChain(scrollState
, elements
);
38 scrollState
.distributeToScrollChainDescendant();
39 assert_equals(0, remainingNumberOfTimesToBeCalled
);
40 for (var i
= 0; i
< elementCount
; ++i
) {
41 assert_equals(elements
[i
].creationOrder
, elements
[i
].calledOrder
);
43 }, "distributeToScrollChainDescendant propagates correctly.");
46 var scrollState
= new ScrollState(100, 0, 0, 0, 0, false, false);
47 window
.internals
.setScrollChain(scrollState
, []);
48 assert_equals(0, remainingNumberOfTimesToBeCalled
);
49 scrollState
.distributeToScrollChainDescendant();
50 assert_equals(0, remainingNumberOfTimesToBeCalled
);
51 }, "distributeToScrollChainDescendant with empty scroll chain does nothing.");