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 378953002: Test framework and tests for CSSOM View smooth scroll (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
(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 ListBoxScrollTopTestCase(testData) {
11 ScrollBehaviorTestCase.call(this, testData);
12 }
13 ListBoxScrollTopTestCase.prototype = Object.create(ScrollBehaviorTestCase.pr ototype);
14 ListBoxScrollTopTestCase.constructor = ListBoxScrollTopTestCase;
15 ListBoxScrollTopTestCase.prototype.run = function() {
16 var element = document.getElementById("listbox");
17 element.style.scrollBehavior = this.css;
18 if (this.js) {
19 element.scrollTop = {y: this.y, behavior: this.js};
20 } else {
21 element.scrollTop = this.y;
22 }
23 }
24
25 var testScrolls = [
26 {js: "instant", css: "instant", index: 2},
27 {js: "instant", css: "smooth", index: 3},
28 {js: "auto", css: "instant", index: 4},
29 {js: "", css: "instant", index: 5},
30 {js: "smooth", css: "instant", waitForEnd: true, index: 15},
31 {js: "smooth", css: "smooth", waitForEnd: true, index: 20},
32 {js: "auto", css: "smooth", waitForEnd: true, index: 30},
33 {js: "", css: "smooth", waitForEnd: true, index: 35},
34 {js: "smooth", css: "instant", waitForEnd: false, index: 410},
35 {js: "smooth", css: "smooth", waitForEnd: false, index: 20},
36 {js: "auto", css: "smooth", waitForEnd: false, index: 400},
37 {js: "", css: "smooth", waitForEnd: false, index: 5},
38 ];
39
40 function initializeContents(listbox)
41 {
42 for (var i = 0; i < numItems; i++) {
43 var option = document.createElement("option");
44 option.appendChild(document.createTextNode(i));
45 listbox.appendChild(option);
46 }
47 }
48
49 function doTest()
50 {
51 var element = document.getElementById("listbox");
52 initializeContents(element);
53 var itemHeight = (listbox.scrollHeight - listbox.clientHeight) / (numItems - listbox.size);
54
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 ListBoxScrollTopTestCase(testScrolls[i]));
61 }
62
63 var scrollBehaviorTest = new ScrollBehaviorTest(element, element, testCase s);
64 scrollBehaviorTest.run();
65 }
66
67 window.addEventListener('load', doTest, false);
68 </script>
69 </head>
70
71 <body>
72 <p>Test that setting scrollTop on a listbox works with both scroll behaviors</ p>
73 <select size="4" id="listbox"></select>
74 </body>
75 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698