OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script src="../resources/js-test.js"></script> | |
4 </head> | |
5 <body> | |
6 | |
7 <p id="description"></p> | |
8 | |
9 <iframe id="frame" src="data:text/html,<body><button id='upper_target'>Upper Tar
get</button><div style='border: 1px solid #000; height: 5000px;'>5000-pixel box<
/div><button id='lower_target'>Lower Target</button></body>"></iframe> | |
10 | |
11 <div id="console"></div> | |
12 | |
13 <script> | |
14 description("Tests that scrolling to make an element visible successfully scroll
s an iframe."); | |
15 | |
16 if (window.testRunner) | |
17 testRunner.waitUntilDone(); | |
18 | |
19 window.jsTestIsAsync = true; | |
20 | |
21 function runTest() { | |
22 window.frame = document.getElementById("frame"); | |
23 window.frameWindow = frame.contentWindow; | |
24 window.frameDoc = frameWindow.document; | |
25 | |
26 var upperTarget = frameDoc.getElementById("upper_target"); | |
27 var lowerTarget = frameDoc.getElementById("lower_target"); | |
28 | |
29 if (window.accessibilityController) { | |
30 lowerTarget.focus(); | |
31 var lowerTargetAccessibleObject = accessibilityController.focusedElement
; | |
32 upperTarget.focus(); | |
33 var upperTargetAccessibleObject = accessibilityController.focusedElement
; | |
34 } | |
35 | |
36 // Reset the initial scroll position (since calling focus() can scroll the p
age too). | |
37 frameWindow.scrollTo(0, 0); | |
38 shouldBe("frameWindow.pageYOffset", "0"); | |
39 | |
40 // Scroll to make lower target visible and check. | |
41 if (window.accessibilityController) | |
42 lowerTargetAccessibleObject.scrollToMakeVisible(); | |
43 window.minYOffset = lowerTarget.offsetTop + lowerTarget.offsetHeight - frame
Window.innerHeight; | |
44 window.maxYOffset = lowerTarget.offsetTop; | |
45 shouldBe("frameWindow.pageYOffset >= minYOffset", "true"); | |
46 shouldBe("frameWindow.pageYOffset <= maxYOffset", "true"); | |
47 | |
48 // Scroll to make upper target visible and check. | |
49 if (window.accessibilityController) | |
50 upperTargetAccessibleObject.scrollToMakeVisible(); | |
51 window.minYOffset = upperTarget.offsetTop + upperTarget.offsetHeight - frame
Window.innerHeight; | |
52 window.maxYOffset = upperTarget.offsetTop; | |
53 shouldBe("frameWindow.pageYOffset >= minYOffset", "true"); | |
54 shouldBe("frameWindow.pageYOffset <= maxYOffset", "true"); | |
55 | |
56 finishJSTest(); | |
57 } | |
58 | |
59 window.addEventListener('load', function() { | |
60 setTimeout(runTest, 10); | |
61 }, false); | |
62 | |
63 </script> | |
64 | |
65 </body> | |
66 </html> | |
OLD | NEW |