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

Side by Side Diff: LayoutTests/fast/scroll-behavior/main-frame-scrollBy.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 <style>
5 #content {
6 width: 7500px;
7 height: 7500px;
8 background-color: blue;
9 }
10 </style>
11 <script src="../../resources/testharness.js"></script>
12 <script src="../../resources/testharnessreport.js"></script>
13 <script src="resources/scroll-behavior-test.js"></script>
14 <script type="text/javascript">
15 function MainFrameScrollByTestCase(testData) {
16 ScrollBehaviorTestCase.call(this, testData);
17 }
18 MainFrameScrollByTestCase.prototype = Object.create(ScrollBehaviorTestCase.p rototype);
19 MainFrameScrollByTestCase.constructor = MainFrameScrollByTestCase;
20 MainFrameScrollByTestCase.prototype.run = function() {
21 document.documentElement.style.scrollBehavior = this.css;
22 if (this.js) {
23 window.scrollBy(this.x, this.y, {behavior: this.js});
24 } else {
25 window.scrollBy(this.x, this.y);
26 }
27 }
Ian Vollick 2014/07/09 14:55:43 nit: I think the OO here is OK, but I wonder if it
ajuma 2014/07/09 20:27:55 Added jsScroll and getEndPosition callbacks. (We d
Ian Vollick 2014/07/10 03:32:42 Thanks for doing that. I think it's a little prett
28
29 MainFrameScrollByTestCase.prototype.setStartPosition = function(currentX, cu rrentY) {
30 ScrollBehaviorTestCase.prototype.setStartPosition.call(this, currentX, cur rentY);
31 this.endX = this.startX + this.x;
32 this.endY = this.startY + this.y;
33 }
34
35 const testScrolls = [
36 {js: "instant", css: "instant", x: 1, y: 2},
37 {js: "instant", css: "smooth", x: 2, y: 3},
38 {js: "auto", css: "instant", x: 3, y: 4},
39 {js: "", css: "instant", x: 4, y: 5},
40 {js: "smooth", css: "instant", waitForEnd: true, x: 10, y: 15},
41 {js: "smooth", css: "smooth", waitForEnd: true, x: 20, y: 25},
42 {js: "auto", css: "smooth", waitForEnd: true, x: 30, y: 35},
43 {js: "", css: "smooth", waitForEnd: true, x: 40, y: 45},
44 {js: "smooth", css: "instant", waitForEnd: false, x: 4000, y: 4100},
45 {js: "smooth", css: "smooth", waitForEnd: false, x: -3900, y: -3850},
46 {js: "auto", css: "smooth", waitForEnd: false, x: 4050, y: 4000},
47 {js: "", css: "smooth", waitForEnd: false, x: -4000, y: -4100},
48 ];
49
50 function doTest()
51 {
52 var testCases = [];
53 for (var i = 0; i < testScrolls.length; i++) {
54 testCases.push(new MainFrameScrollByTestCase(testScrolls[i]));
55 }
56
57 var scrollBehaviorTest = new ScrollBehaviorTest(document.documentElement,
58 document,
59 testCases);
60 scrollBehaviorTest.run();
61 }
62
63 window.addEventListener('load', doTest, false);
64 </script>
65 </head>
66
67 <body>
68 <p>Test that calling scrollBy on the main frame works with both scroll behavio rs</p>
69 <div id="content"></div>
70 </body>
71 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698