| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <base href="/inspector-debug/"></base> | |
| 4 <script src="/inspector-debug/Runtime.js"></script> | |
| 5 <script src="/inspector-unit/inspector-unit-test.js"></script> | |
| 6 <script> | |
| 7 function test() { | |
| 8 var items = []; | |
| 9 var heights = []; | |
| 10 for (var i = 0; i < 100; i++){ | |
| 11 items[i] = document.createElement("div"); | |
| 12 items[i].style.height = (heights[i] = (i % 4) ? 50 : 28) + "px"; | |
| 13 items[i].textContent = i; | |
| 14 } | |
| 15 var viewport = new UI.StaticViewportControl({ | |
| 16 fastItemHeight: i => heights[i], | |
| 17 itemCount: _ => items.length, | |
| 18 itemElement: i => items[i] | |
| 19 }); | |
| 20 viewport.element.style.height = "300px"; | |
| 21 UI.inspectorView.element.appendChild(viewport.element); | |
| 22 | |
| 23 viewport.refresh(); | |
| 24 dumpViewport(); | |
| 25 | |
| 26 viewport.forceScrollItemToBeFirst(26); | |
| 27 dumpViewport(); | |
| 28 | |
| 29 viewport.scrollItemIntoView(33); | |
| 30 dumpViewport(); | |
| 31 | |
| 32 viewport.scrollItemIntoView(30); | |
| 33 dumpViewport(); | |
| 34 | |
| 35 viewport.forceScrollItemToBeFirst(30); | |
| 36 dumpViewport(); | |
| 37 | |
| 38 viewport.forceScrollItemToBeLast(88); | |
| 39 dumpViewport(); | |
| 40 | |
| 41 for (var i = 0; i < 100; i++) | |
| 42 items[i].style.height = (heights[i] = (i % 2) ? 55 : 63) + "px"; | |
| 43 viewport.refresh(); | |
| 44 viewport.forceScrollItemToBeLast(88); | |
| 45 dumpViewport(); | |
| 46 | |
| 47 UnitTest.completeTest(); | |
| 48 | |
| 49 function dumpViewport() | |
| 50 { | |
| 51 UnitTest.addResult("First:" + viewport.firstVisibleIndex()); | |
| 52 UnitTest.addResult("Last:" + viewport.lastVisibleIndex()); | |
| 53 UnitTest.addResult("Active Items:" + viewport._innerElement.children.len
gth); | |
| 54 UnitTest.addResult(""); | |
| 55 } | |
| 56 } | |
| 57 </script> | |
| 58 </head> | |
| 59 <body> | |
| 60 This tests if the StaticViewportControl works properly. | |
| 61 </body> | |
| 62 </html> | |
| OLD | NEW |