Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / accessibility / scroll-to-make-visible-nested-2.html
blob9f5c402621ba5d4560aba7ddc60f3863571fb567
1 <html>
2 <head>
3 <script src="../resources/js-test.js"></script>
4 </head>
5 <body>
7 <p id="description"></p>
9 <div id="container" style="width: 100px; overflow: scroll">
10 <div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel box</div>
11 <button id="target1">Target</button>
12 <button id="target2">Target</button>
13 <button id="target3">Target</button>
14 <div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel box</div>
15 </div>
17 <div id="console"></div>
19 <script>
20 description("Tests that scrolling to make an element visible works when the inner scroll container doesn't need to be scrolled, but the other one does.");
22 function runTest() {
23 window.container = document.getElementById("container");
24 window.target1 = document.getElementById("target1");
25 window.target2 = document.getElementById("target2");
26 window.target3 = document.getElementById("target3");
28 if (window.accessibilityController) {
29 target1.focus();
30 var target1AccessibleObject = accessibilityController.focusedElement;
31 target2.focus();
32 var target2AccessibleObject = accessibilityController.focusedElement;
33 target3.focus();
34 var target3AccessibleObject = accessibilityController.focusedElement;
37 // Reset the initial scroll positions (since calling focus() can scroll the page too).
38 window.scrollTo(0, 0);
39 container.scrollTop = 0;
40 shouldBe("window.pageYOffset", "0");
41 shouldBe("container.scrollTop", "0");
42 shouldBeGreaterThanOrEqual("target1.getBoundingClientRect().top", "5000");
44 // Scroll to make the middle target visible.
45 if (window.accessibilityController)
46 target2AccessibleObject.scrollToMakeVisible();
48 // Instead of testing the exact scroll offsets of the two containers, just test that
49 // the new absolute position of the target is on-screen.
50 shouldBeGreaterThanOrEqual("window.innerHeight", "target2.getBoundingClientRect().bottom");
52 // Make sure that calling scrollToMakeVisible on target1 and target3 don't result in any
53 // scrolling, because they should already be within the viewport.
54 window.target2top = target2.getBoundingClientRect().top;
55 if (window.accessibilityController)
56 target1AccessibleObject.scrollToMakeVisible();
57 shouldBe("target2top", "target2.getBoundingClientRect().top");
58 if (window.accessibilityController)
59 target3AccessibleObject.scrollToMakeVisible();
60 shouldBe("target2top", "target2.getBoundingClientRect().top");
62 finishJSTest();
65 runTest();
67 </script>
69 </body>
70 </html>