3 <script src=
"../resources/js-test.js"></script>
7 <p id=
"description"></p>
9 <iframe id=
"frame" src=
"data:text/html,<body><button id='upper_target'>Upper Target</button><div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div><button id='lower_target'>Lower Target</button></body>"></iframe>
11 <div id=
"console"></div>
14 description("Tests that scrolling to make an element visible successfully scrolls an iframe.");
16 if (window
.testRunner
)
17 testRunner
.waitUntilDone();
19 window
.jsTestIsAsync
= true;
22 window
.frame
= document
.getElementById("frame");
23 window
.frameWindow
= frame
.contentWindow
;
24 window
.frameDoc
= frameWindow
.document
;
26 var upperTarget
= frameDoc
.getElementById("upper_target");
27 var lowerTarget
= frameDoc
.getElementById("lower_target");
29 if (window
.accessibilityController
) {
31 var lowerTargetAccessibleObject
= accessibilityController
.focusedElement
;
33 var upperTargetAccessibleObject
= accessibilityController
.focusedElement
;
36 // Reset the initial scroll position (since calling focus() can scroll the page too).
37 frameWindow
.scrollTo(0, 0);
38 shouldBe("frameWindow.pageYOffset", "0");
40 // Scroll to make lower target visible and check.
41 if (window
.accessibilityController
)
42 lowerTargetAccessibleObject
.scrollToMakeVisible();
43 window
.minYOffset
= lowerTarget
.offsetTop
+ lowerTarget
.offsetHeight
- frameWindow
.innerHeight
;
44 window
.maxYOffset
= lowerTarget
.offsetTop
;
45 shouldBe("frameWindow.pageYOffset >= minYOffset", "true");
46 shouldBe("frameWindow.pageYOffset <= maxYOffset", "true");
48 // Scroll to make upper target visible and check.
49 if (window
.accessibilityController
)
50 upperTargetAccessibleObject
.scrollToMakeVisible();
51 window
.minYOffset
= upperTarget
.offsetTop
+ upperTarget
.offsetHeight
- frameWindow
.innerHeight
;
52 window
.maxYOffset
= upperTarget
.offsetTop
;
53 shouldBe("frameWindow.pageYOffset >= minYOffset", "true");
54 shouldBe("frameWindow.pageYOffset <= maxYOffset", "true");
59 window
.addEventListener('load', function() {
60 setTimeout(runTest
, 10);