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