OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>ScrollState constructor behaves correctly</title> |
| 6 <script src="../../../resources/testharness.js"></script> |
| 7 <script src="../../../resources/testharnessreport.js"></script> |
| 8 </head> |
| 9 <body> |
| 10 <script> |
| 11 test(function() { |
| 12 assert_true('ScrollState' in window, "'ScrollState' in window"); |
| 13 // TODO(tdresser): Don't rely on window.internals. See crbug.com/483091 for de
tails. |
| 14 assert_true(window.internals !== null, "'ScrollState' in window"); |
| 15 }, "These tests only work with scroll customization enabled."); |
| 16 |
| 17 var elementCount = 10; |
| 18 var remainingNumberOfTimesToBeCalled = elementCount; |
| 19 |
| 20 var distributeScroll = function(scrollState) { |
| 21 this.calledOrder = elementCount - remainingNumberOfTimesToBeCalled; |
| 22 remainingNumberOfTimesToBeCalled--; |
| 23 scrollState.distributeToScrollChainDescendant(); |
| 24 } |
| 25 |
| 26 var elements = []; |
| 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-sc
roll"); |
| 31 elements.push(element); |
| 32 } |
| 33 |
| 34 if ('ScrollState' in window && window.internals) { |
| 35 test(function() { |
| 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); |
| 42 } |
| 43 }, "distributeToScrollChainDescendant propagates correctly."); |
| 44 |
| 45 test(function() { |
| 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."); |
| 52 } |
| 53 </script> |
| 54 </body> |
| 55 </html> |
OLD | NEW |