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

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

Issue 134443003: Implement CSSOM Smooth Scroll API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/scroll-behavior/listbox-scrollTop.html
diff --git a/LayoutTests/fast/scroll-behavior/listbox-scrollTop.html b/LayoutTests/fast/scroll-behavior/listbox-scrollTop.html
new file mode 100644
index 0000000000000000000000000000000000000000..c2c100782667146e43397e3fdf4df578a78d72ef
--- /dev/null
+++ b/LayoutTests/fast/scroll-behavior/listbox-scrollTop.html
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
+ <script src="resources/scroll-behavior-test.js"></script>
+ <script type="text/javascript">
+ const numItems = 500;
+ var instantScrolls = [
Ian Vollick 2014/02/06 16:02:31 If you make an object for the behavior test case,
+ {js: "instant", css: "instant", index: 2},
+ {js: "instant", css: "smooth", index: 3},
+ {js: "auto", css: "instant", index: 4},
+ {js: "", css: "instant", index: 5}
+ ];
+
+ var smoothScrolls = [
+ {js: "smooth", css: "instant", waitForEnd: true, index: 15},
+ {js: "smooth", css: "smooth", waitForEnd: true, index: 20},
+ {js: "auto", css: "smooth", waitForEnd: true, index: 30},
+ {js: "", css: "smooth", waitForEnd: true, index: 35},
+ {js: "smooth", css: "instant", waitForEnd: false, index: 410},
+ {js: "smooth", css: "smooth", waitForEnd: false, index: 20},
+ {js: "auto", css: "smooth", waitForEnd: false, index: 400},
+ {js: "", css: "smooth", waitForEnd: false, index: 5},
+ ];
+
+ function runTestCase(testCase)
+ {
+ var element = document.getElementById("listbox");
+ if (testCase.js)
+ element.scrollTop = {y: testCase.y, behavior: testCase.js};
+ else
+ element.scrollTop = testCase.y;
+ }
+
+ function endX(testCase, startX)
+ {
+ return startX;
+ }
+
+ function endY(testCase)
+ {
+ return testCase.y;
+ }
+
+ function initializeContents(listbox)
+ {
+ for (var i = 0; i < numItems; i++) {
+ var option = document.createElement("option");
+ option.appendChild(document.createTextNode(i));
+ listbox.appendChild(option);
+ }
+ }
+
+ function initializeTestCases(listbox)
+ {
+ var itemHeight = (listbox.scrollHeight - listbox.clientHeight) / (numItems - listbox.size);
+ for (var i = 0; i < instantScrolls.length; i++) {
+ instantScrolls[i].y = instantScrolls[i].index * itemHeight;
+ }
+ for (var i = 0; i < smoothScrolls.length; i++) {
+ smoothScrolls[i].y = smoothScrolls[i].index * itemHeight;
+ }
+ }
+
+ function doTest()
+ {
+ var element = document.getElementById("listbox");
+ initializeContents(element);
+ initializeTestCases(element);
+ runScrollBehaviorTests(element,
+ element,
+ instantScrolls,
+ smoothScrolls,
+ runTestCase,
+ endX,
+ endY);
+ }
+
+ window.addEventListener('load', doTest, false);
+ </script>
+</head>
+
+<body>
+ <p>Test that setting scrollTop on a listbox works with both scroll behaviors</p>
+ <select size="4" id="listbox"></select>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698