OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <style> | 4 <style> |
5 #content { | 5 #content { |
6 width: 7500px; | 6 width: 7500px; |
7 height: 7500px; | 7 height: 7500px; |
8 background-color: blue; | 8 background-color: blue; |
9 } | 9 } |
10 </style> | 10 </style> |
(...skipping 15 matching lines...) Expand all Loading... |
26 return endPosition; | 26 return endPosition; |
27 } | 27 } |
28 | 28 |
29 function jsScroll(testCase) { | 29 function jsScroll(testCase) { |
30 if (testCase.js) { | 30 if (testCase.js) { |
31 var scrollToOptions = {behavior: testCase.js}; | 31 var scrollToOptions = {behavior: testCase.js}; |
32 if (testCase.x) | 32 if (testCase.x) |
33 scrollToOptions.left = testCase.x; | 33 scrollToOptions.left = testCase.x; |
34 if (testCase.y) | 34 if (testCase.y) |
35 scrollToOptions.top = testCase.y; | 35 scrollToOptions.top = testCase.y; |
36 document.body.scrollBy(scrollToOptions); | 36 document.scrollingElement.scrollBy(scrollToOptions); |
37 } else { | 37 } else { |
38 document.body.scrollBy(testCase.x, testCase.y); | 38 document.scrollingElement.scrollBy(testCase.x, testCase.y); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 const testScrolls = [ | 42 const testScrolls = [ |
43 {js: "instant", css: "auto", x: 1, y: 2}, | 43 {js: "instant", css: "auto", x: 1, y: 2}, |
44 {js: "instant", css: "smooth", x: 2, y: 3}, | 44 {js: "instant", css: "smooth", x: 2, y: 3}, |
45 {js: "auto", css: "auto", x: 3, y: 4}, | 45 {js: "auto", css: "auto", x: 3, y: 4}, |
46 {js: "", css: "auto", x: 4, y: 5}, | 46 {js: "", css: "auto", x: 4, y: 5}, |
47 {js: "auto", css: "auto", x: 3}, | 47 {js: "auto", css: "auto", x: 3}, |
48 {js: "auto", css: "auto", y: 4}, | 48 {js: "auto", css: "auto", y: 4}, |
(...skipping 10 matching lines...) Expand all Loading... |
59 {js: "", css: "smooth", waitForEnd: false, x: -4000, y: -4100}, | 59 {js: "", css: "smooth", waitForEnd: false, x: -4000, y: -4100}, |
60 ]; | 60 ]; |
61 | 61 |
62 function doTest() | 62 function doTest() |
63 { | 63 { |
64 var testCases = []; | 64 var testCases = []; |
65 for (var i = 0; i < testScrolls.length; i++) { | 65 for (var i = 0; i < testScrolls.length; i++) { |
66 testCases.push(new ScrollBehaviorTestCase(testScrolls[i])); | 66 testCases.push(new ScrollBehaviorTestCase(testScrolls[i])); |
67 } | 67 } |
68 | 68 |
69 var scrollBehaviorTest = new ScrollBehaviorTest(document.body, | 69 var scrollBehaviorTest = new ScrollBehaviorTest(document.scrollingElement, |
70 document, | 70 document, |
71 testCases, | 71 testCases, |
72 getEndPosition, | 72 getEndPosition, |
73 jsScroll); | 73 jsScroll); |
74 scrollBehaviorTest.run(); | 74 scrollBehaviorTest.run(); |
75 } | 75 } |
76 | 76 |
77 window.addEventListener('load', doTest, false); | 77 window.addEventListener('load', doTest, false); |
78 </script> | 78 </script> |
79 </head> | 79 </head> |
80 | 80 |
81 <body> | 81 <body> |
82 <p>Test that calling scrollBy on the main frame's document element works with
both scroll behaviors</p> | 82 <p>Test that calling scrollBy on the main frame's document element works with
both scroll behaviors</p> |
83 <div id="content"></div> | 83 <div id="content"></div> |
84 </body> | 84 </body> |
85 </html> | 85 </html> |
OLD | NEW |