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">
17 function getEndPosition(testCase
, startPosition
) {
19 // If the pageScaleFactor is set to 1, it means that there is no pinch-zoom,
20 // i.e. the endPosition = max scroll.
22 if (testCase
.pageScaleFactor
== 1) {
23 endPosition
.x
= maxScrollWidth
;
25 endPosition
.x
= testCase
.x
;
28 endPosition
.x
= startPosition
.x
;
32 if (testCase
.pageScaleFactor
== 1) {
33 endPosition
.y
= maxScrollHeight
;
35 endPosition
.y
= testCase
.y
;
38 endPosition
.y
= startPosition
.y
;
44 function jsScroll(testCase
) {
46 var scrollToOptions
= {behavior
: testCase
.js
};
48 scrollToOptions
.left
= testCase
.x
;
50 scrollToOptions
.top
= testCase
.y
;
51 document
.scrollingElement
.scrollTo(scrollToOptions
);
53 document
.scrollingElement
.scrollTo(testCase
.x
, testCase
.y
);
58 {js
: "smooth", css
: "smooth", x
: 0, y
: 1000, pageScaleFactor
: 1},
59 {js
: "smooth", css
: "smooth", x
: 10, y
: 400, pageScaleFactor
: 4},
60 {js
: "instant", css
: "instant", x
: 0, y
: 1000, pageScaleFactor
: 1},
61 {js
: "instant", css
: "instant", x
: 10, y
: 400, pageScaleFactor
: 4},
67 maxScrollHeight
= document
.scrollingElement
.scrollHeight
- window
.innerHeight
;
68 maxScrollWidth
= document
.scrollingElement
.scrollWidth
- window
.innerWidth
;
70 for (var i
= 0; i
< testScrolls
.length
; i
++) {
71 testCases
.push(new ScrollBehaviorTestCase(testScrolls
[i
]));
74 var scrollBehaviorTest
= new ScrollBehaviorTest(document
.scrollingElement
,
79 scrollBehaviorTest
.run();
82 window
.addEventListener('load', doTest
, false);
87 <p>Test that scrollTo works on the visual viewport.
</p>
88 <div id=
"content"></div>