OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/testharness.js"></script> | |
5 <script src="../../resources/testharnessreport.js"></script> | |
6 <script src="resources/scroll-interruption-test.js"></script> | |
7 <script type="text/javascript"> | |
8 const numItems = 500; | |
9 | |
10 function jsScroll(y) { | |
11 document.getElementById('listbox').scrollTop = {y: y, behavior: 'smooth'}; | |
12 } | |
13 | |
14 function initializeContents(listbox) { | |
15 for (var i = 0; i < numItems; i++) { | |
16 var option = document.createElement('option'); | |
17 option.appendChild(document.createTextNode(i)); | |
18 listbox.appendChild(option); | |
19 } | |
20 } | |
21 | |
22 function initializeTest(indexTargets, targets, innerPoint, listbox) { | |
23 var itemHeight = (listbox.scrollHeight - listbox.clientHeight) / (numItems
- listbox.size); | |
24 | |
25 // Convert from listbox item index to scroll offset. | |
26 targets.y_min = indexTargets.index_min * itemHeight; | |
27 targets.y_mid = indexTargets.index_mid * itemHeight; | |
28 targets.y_max = indexTargets.index_max * itemHeight; | |
29 | |
30 var boundingRect = listbox.getBoundingClientRect(); | |
31 innerPoint.x = (boundingRect.left + boundingRect.right)/2; | |
32 innerPoint.y = (boundingRect.top + boundingRect.bottom)/2; | |
33 } | |
34 | |
35 function doTest() { | |
36 var indexTargets = {index_min: 3, index_mid: 200, index_max: 400}; | |
37 var targets = {}; | |
38 var innerPoint = {}; | |
39 var element = document.getElementById('listbox'); | |
40 initializeContents(element); | |
41 initializeTest(indexTargets, targets, innerPoint, element); | |
42 var scrollInterruptionTest = new SmoothScrollInterruptionTest(element, | |
43 innerPoint, | |
44 targets, | |
45 jsScroll); | |
46 scrollInterruptionTest.run(); | |
47 } | |
48 | |
49 window.addEventListener('load', doTest, false); | |
50 </script> | |
51 </head> | |
52 | |
53 <body> | |
54 <p>Test that interrupting a smooth scroll on a listbox works with both scroll
behaviors and with input</p> | |
55 <select size="4" id="listbox"></select> | |
56 </body> | |
57 </html> | |
OLD | NEW |