Chromium Code Reviews| 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 | |
| 12 if (!window.internals || !window.internals.runtimeFlags.scrollCustomizationEnabl ed) { | |
| 13 console.log("These tests only work with window.internals exposed, " + | |
| 14 "and require scroll customization."); | |
| 15 done(); | |
| 16 } | |
| 17 | |
| 18 var elementCount = 10; | |
| 19 var remainingNumberOfTimesToBeCalled = elementCount; | |
| 20 | |
| 21 var distributeScroll = function(scrollState) { | |
| 22 this.calledOrder = elementCount - remainingNumberOfTimesToBeCalled; | |
| 23 remainingNumberOfTimesToBeCalled--; | |
| 24 scrollState.distributeToScrollChainDescendant(); | |
| 25 } | |
| 26 | |
| 27 var elements = []; | |
| 28 for (var i = 0; i < elementCount; ++i) { | |
| 29 var element = document.createElement("div"); | |
| 30 element.creationOrder = i; | |
| 31 element.distributeScroll = distributeScroll; | |
| 32 elements.push(element); | |
| 33 } | |
| 34 | |
| 35 test(function() { | |
| 36 var scrollState = new ScrollState(100, 0, 0, 0, 0, false, false); | |
| 37 window.internals.setScrollChain(scrollState, elements); | |
|
Rick Byers
2015/04/10 14:51:44
To what extent do you think you could test this AP
tdresser
2015/05/08 18:23:01
I've filed a bug to enable setting the scroll chai
| |
| 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 }, "distributeToScrollChainDescendant propagates correctly."); | |
| 43 | |
| 44 test(function() { | |
| 45 var scrollState = new ScrollState(100, 0, 0, 0, 0, false, false); | |
| 46 window.internals.setScrollChain(scrollState, []); | |
| 47 assert_equals(0, remainingNumberOfTimesToBeCalled); | |
| 48 scrollState.distributeToScrollChainDescendant(); | |
| 49 assert_equals(0, remainingNumberOfTimesToBeCalled); | |
| 50 }, "distributeToScrollChainDescendant with empty scroll chain does nothing."); | |
| 51 | |
| 52 </script> | |
| 53 </body> | |
| 54 </html> | |
| OLD | NEW |