OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <style> |
| 5 #subframe { |
| 6 width: 200px; |
| 7 height: 200px; |
| 8 } |
| 9 </style> |
| 10 <script src="../../resources/testharness.js"></script> |
| 11 <script src="../../resources/testharnessreport.js"></script> |
| 12 <script src="resources/scroll-behavior-test.js"></script> |
| 13 <script type="text/javascript"> |
| 14 function getEndPosition(testCase, startPosition) { |
| 15 var endPosition = {}; |
| 16 if (testCase.x) |
| 17 endPosition.x = testCase.x; |
| 18 else |
| 19 endPosition.x = startPosition.x; |
| 20 |
| 21 if (testCase.y) |
| 22 endPosition.y = testCase.y; |
| 23 else |
| 24 endPosition.y = startPosition.y; |
| 25 |
| 26 return endPosition; |
| 27 } |
| 28 |
| 29 function jsScroll(testCase) { |
| 30 var subframe = document.getElementById("subframe"); |
| 31 if (testCase.js) { |
| 32 var scrollToOptions = {behavior: testCase.js}; |
| 33 if (testCase.x) |
| 34 scrollToOptions.left = testCase.x; |
| 35 if (testCase.y) |
| 36 scrollToOptions.top = testCase.y; |
| 37 subframe.contentDocument.documentElement.scroll(scrollToOptions); |
| 38 } else { |
| 39 subframe.contentDocument.documentElement.scroll(testCase.x, testCase.y); |
| 40 } |
| 41 } |
| 42 |
| 43 const testScrolls = [ |
| 44 {js: "instant", css: "auto", x: 1, y: 2}, |
| 45 {js: "instant", css: "smooth", x: 2, y: 3}, |
| 46 {js: "auto", css: "auto", x: 3, y: 4}, |
| 47 {js: "", css: "auto", x: 4, y: 5}, |
| 48 {js: "auto", css: "auto", x: 3}, |
| 49 {js: "auto", css: "auto", y: 4}, |
| 50 {js: "auto", css: "auto"}, |
| 51 {js: "smooth", css: "auto", waitForEnd: true, x: 10, y: 15}, |
| 52 {js: "smooth", css: "smooth", waitForEnd: true, x: 20, y: 25}, |
| 53 {js: "auto", css: "smooth", waitForEnd: true, x: 30, y: 35}, |
| 54 {js: "", css: "smooth", waitForEnd: true, x: 40, y: 45}, |
| 55 {js: "auto", css: "smooth", waitForEnd: true, x: 45}, |
| 56 {js: "auto", css: "smooth", waitForEnd: true, y: 40}, |
| 57 {js: "smooth", css: "auto", waitForEnd: false, x: 4000, y: 4100}, |
| 58 {js: "smooth", css: "smooth", waitForEnd: false, x: 15, y: 20}, |
| 59 {js: "auto", css: "smooth", waitForEnd: false, x: 4100, y: 4000}, |
| 60 {js: "", css: "smooth", waitForEnd: false, x: 10, y: 5}, |
| 61 ]; |
| 62 |
| 63 function doTest() |
| 64 { |
| 65 var testCases = []; |
| 66 for (var i = 0; i < testScrolls.length; i++) { |
| 67 testCases.push(new ScrollBehaviorTestCase(testScrolls[i])); |
| 68 } |
| 69 |
| 70 var subframe = document.getElementById("subframe"); |
| 71 var scrollBehaviorTest = new ScrollBehaviorTest(subframe.contentDocument.d
ocumentElement, |
| 72 subframe.contentDocument, |
| 73 testCases, |
| 74 getEndPosition, |
| 75 jsScroll); |
| 76 scrollBehaviorTest.run(); |
| 77 } |
| 78 |
| 79 window.addEventListener('load', doTest, false); |
| 80 </script> |
| 81 </head> |
| 82 |
| 83 <body> |
| 84 <p>Test that calling scroll on a subframe's document element works with both s
croll behaviors</p> |
| 85 <iframe id="subframe" src="resources/large-subframe.html"></iframe> |
| 86 </body> |
| 87 </html> |
OLD | NEW |