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

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

Issue 782793002: Update Element API for CSSOM smooth scrolling to match the spec (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address review comments Created 6 years 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
(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-behavior-test.js"></script>
7 <script type="text/javascript">
8 const numItems = 500;
9
10 function getEndPosition(testCase, startPosition) {
11 var endPosition = {};
12 endPosition.x = startPosition.x;
13 endPosition.y = testCase.y;
14 return endPosition;
15 }
16
17 function jsScroll(testCase) {
18 var element = document.getElementById("listbox");
19 if (testCase.js) {
20 element.scrollTop = {y: testCase.y, behavior: testCase.js};
21 } else {
22 element.scrollTop = testCase.y;
23 }
24 }
25
26 var testScrolls = [
27 {js: "instant", css: "auto", index: 2},
28 {js: "instant", css: "smooth", index: 3},
29 {js: "auto", css: "auto", index: 4},
30 {js: "", css: "auto", index: 5},
31 {js: "smooth", css: "auto", waitForEnd: true, index: 15},
32 {js: "smooth", css: "smooth", waitForEnd: true, index: 20},
33 {js: "auto", css: "smooth", waitForEnd: true, index: 30},
34 {js: "", css: "smooth", waitForEnd: true, index: 35},
35 {js: "smooth", css: "auto", waitForEnd: false, index: 410},
36 {js: "smooth", css: "smooth", waitForEnd: false, index: 20},
37 {js: "auto", css: "smooth", waitForEnd: false, index: 400},
38 {js: "", css: "smooth", waitForEnd: false, index: 5},
39 ];
40
41 function initializeContents(listbox)
42 {
43 for (var i = 0; i < numItems; i++) {
44 var option = document.createElement("option");
45 option.appendChild(document.createTextNode(i));
46 listbox.appendChild(option);
47 }
48 }
49
50 function doTest()
51 {
52 var element = document.getElementById("listbox");
53 initializeContents(element);
54 var itemHeight = Math.floor(listbox.clientHeight / listbox.size);
55 var testCases = [];
56 for (var i = 0; i < testScrolls.length; i++) {
57 // Convert from list box item index to a scroll offset.
58 testScrolls[i].y = testScrolls[i].index * itemHeight;
59 testScrolls[i].x = 0;
60 testCases.push(new ScrollBehaviorTestCase(testScrolls[i]));
61 }
62
63 var scrollBehaviorTest = new ScrollBehaviorTest(element,
64 element,
65 testCases,
66 getEndPosition,
67 jsScroll);
68 scrollBehaviorTest.run();
69 }
70
71 window.addEventListener('load', doTest, false);
72 </script>
73 </head>
74
75 <body>
76 <p>Test that setting scrollTop on a listbox works with both scroll behaviors</ p>
77 <select size="4" id="listbox"></select>
78 </body>
79 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698