Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / accessibility / scroll-to-global-point-iframe-nested.html
blob26c2a7a09719a9c45b8ce1a35e04b006e7e074b4
1 <html>
2 <head>
3 <script src="../resources/js-test.js"></script>
4 </head>
5 <body>
7 <p id="description"></p>
9 <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
11 <!-- The contents of this iframe, more nicely formatted:
12 <body>
13 <style>
14 button {
15 border: 0;
17 </style>
18 <div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div>
19 <div id='container' style='height: 100px; overflow: scroll'>
20 <div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div>
21 <button id='target'>Target</button>
22 <div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div>
23 </div>
24 <div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div>
25 </body>
26 -->
27 <iframe id="frame" src="data:text/html,<body><style>button { border: 0; }</style><div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div><div id='container' style='height: 100px; overflow: scroll'><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><div style='border: 1px solid #000; height: 5000px;'>5000-pixel box</div></body>"></iframe>
29 <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
31 <div id="console"></div>
33 <script>
34 description("Tests that scrolling to move an element to a specific point successfully scrolls both an iframe and a div with overflow.");
36 if (window.testRunner)
37 testRunner.waitUntilDone();
39 window.jsTestIsAsync = true;
41 function runTest() {
42 window.frame = document.getElementById("frame");
43 window.frameWindow = frame.contentWindow;
44 window.frameDoc = frameWindow.document;
45 window.container = frameDoc.getElementById("container");
46 window.target = frameDoc.getElementById("target");
48 if (window.accessibilityController) {
49 target.focus();
50 var targetAccessibleObject = accessibilityController.focusedElement;
53 // Reset the initial scroll position (since calling focus() can scroll the page too).
54 window.scrollTo(0, 0);
55 frameWindow.scrollTo(0, 0);
56 container.scrollTop = 0;
57 shouldBe("window.pageYOffset", "0");
58 shouldBe("frameWindow.pageYOffset", "0");
59 shouldBe("container.scrollTop", "0");
61 // Scroll to various locations and check.
62 if (window.accessibilityController)
63 targetAccessibleObject.scrollToGlobalPoint(0, 0);
64 shouldBe("target.getBoundingClientRect().top", "0");
65 if (window.accessibilityController)
66 targetAccessibleObject.scrollToGlobalPoint(0, 300);
67 shouldBe("target.getBoundingClientRect().top", "300");
68 if (window.accessibilityController)
69 targetAccessibleObject.scrollToGlobalPoint(0, 3000);
70 shouldBe("target.getBoundingClientRect().top", "3000");
72 finishJSTest();
75 window.addEventListener('load', function() {
76 setTimeout(runTest, 10);
77 }, false);
79 </script>
81 </body>
82 </html>