blob: 6351c30570e925e2ca73c1262be1ec290c9f28b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<html>
<head>
<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
<script src="../fast/js/resources/js-test-pre.js"></script>
<style>
button {
border: 0;
}
</style>
</head>
<body>
<p id="description"></p>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<button id="target">Target</button>
<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
<div id="console"></div>
<script>
description("Tests that scrolling an element to a specific point successfully scrolls the main window.");
function runTest() {
var target = document.getElementById("target");
if (window.accessibilityController) {
target.focus();
var targetAccessibleObject = accessibilityController.focusedElement;
}
// Reset the initial scroll position (since calling focus() can scroll the page too).
window.scrollTo(0, 0);
shouldBe("window.pageYOffset", "0");
// Scroll to various locations and check.
if (window.accessibilityController)
targetAccessibleObject.scrollToGlobalPoint(0, 0);
shouldBe("target.getBoundingClientRect().top", "0");
if (window.accessibilityController)
targetAccessibleObject.scrollToGlobalPoint(0, 300);
shouldBe("target.getBoundingClientRect().top", "300");
if (window.accessibilityController)
targetAccessibleObject.scrollToGlobalPoint(0, 3000);
shouldBe("target.getBoundingClientRect().top", "3000");
finishJSTest();
}
runTest();
</script>
</body>
</html>
|