Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: LayoutTests/fast/scroll-behavior/listbox-scrollTop.html

Issue 347773002: Implement select listbox using shadow DOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/testharness.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script> 5 <script src="../../resources/testharnessreport.js"></script>
6 <script src="resources/scroll-behavior-test.js"></script> 6 <script src="resources/scroll-behavior-test.js"></script>
7 <script type="text/javascript"> 7 <script type="text/javascript">
8 const numItems = 500; 8 const numItems = 500;
9 9
10 function getEndPosition(testCase, startPosition) { 10 function getEndPosition(testCase, startPosition) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 var option = document.createElement("option"); 44 var option = document.createElement("option");
45 option.appendChild(document.createTextNode(i)); 45 option.appendChild(document.createTextNode(i));
46 listbox.appendChild(option); 46 listbox.appendChild(option);
47 } 47 }
48 } 48 }
49 49
50 function doTest() 50 function doTest()
51 { 51 {
52 var element = document.getElementById("listbox"); 52 var element = document.getElementById("listbox");
53 initializeContents(element); 53 initializeContents(element);
54 var itemHeight = (listbox.scrollHeight - listbox.clientHeight) / (numItems - listbox.size); 54 var itemHeight = Math.floor(listbox.clientHeight / listbox.size);
55
56 var testCases = []; 55 var testCases = [];
57 for (var i = 0; i < testScrolls.length; i++) { 56 for (var i = 0; i < testScrolls.length; i++) {
58 // Convert from list box item index to a scroll offset. 57 // Convert from list box item index to a scroll offset.
59 testScrolls[i].y = testScrolls[i].index * itemHeight; 58 testScrolls[i].y = testScrolls[i].index * itemHeight;
60 testScrolls[i].x = 0; 59 testScrolls[i].x = 0;
61 testCases.push(new ScrollBehaviorTestCase(testScrolls[i])); 60 testCases.push(new ScrollBehaviorTestCase(testScrolls[i]));
62 } 61 }
63 62
64 var scrollBehaviorTest = new ScrollBehaviorTest(element, 63 var scrollBehaviorTest = new ScrollBehaviorTest(element,
65 element, 64 element,
66 testCases, 65 testCases,
67 getEndPosition, 66 getEndPosition,
68 jsScroll); 67 jsScroll);
69 scrollBehaviorTest.run(); 68 scrollBehaviorTest.run();
70 } 69 }
71 70
72 window.addEventListener('load', doTest, false); 71 window.addEventListener('load', doTest, false);
73 </script> 72 </script>
74 </head> 73 </head>
75 74
76 <body> 75 <body>
77 <p>Test that setting scrollTop on a listbox works with both scroll behaviors</ p> 76 <p>Test that setting scrollTop on a listbox works with both scroll behaviors</ p>
78 <select size="4" id="listbox"></select> 77 <select size="4" id="listbox"></select>
79 </body> 78 </body>
80 </html> 79 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698