OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../resources/js-test.js"></script> | 3 <script src="../resources/js-test.js"></script> |
4 </head> | 4 </head> |
5 <body> | 5 <body> |
6 | 6 |
7 <p id="description"></p> | 7 <p id="description"></p> |
8 | 8 |
9 <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div> | 9 <div id="container" style="width: 100px; overflow: scroll"> |
10 | 10 <div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel
box</div> |
11 <div id="outer_container" style="height: 100px; overflow: scroll"> | 11 <button id="target">Target</button> |
12 <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div> | 12 <div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel
box</div> |
13 <div id="inner_container" style="height: 100px; overflow: scroll"> | |
14 <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div> | |
15 <button id="target">Target</button> | |
16 </div> | |
17 </div> | 13 </div> |
18 | 14 |
19 <div id="console"></div> | 15 <div id="console"></div> |
20 | 16 |
21 <script> | 17 <script> |
22 description("Tests that scrolling to make an element visible successfully scroll
s multiple nested scrolling views'."); | 18 description("Tests that scrolling to make an element visible works when the inne
r scroll container doesn't need to be scrolled, but the other one does."); |
23 | 19 |
24 function runTest() { | 20 function runTest() { |
25 window.outerContainer = document.getElementById("outer_container"); | 21 window.container = document.getElementById("container"); |
26 window.innerContainer = document.getElementById("inner_container"); | |
27 window.target = document.getElementById("target"); | 22 window.target = document.getElementById("target"); |
28 | 23 |
29 if (window.accessibilityController) { | 24 if (window.accessibilityController) { |
30 target.focus(); | 25 target.focus(); |
31 var targetAccessibleObject = accessibilityController.focusedElement; | 26 var targetAccessibleObject = accessibilityController.focusedElement; |
32 } | 27 } |
33 | 28 |
34 // Reset the initial scroll positions (since calling focus() can scroll the
page too). | 29 // Reset the initial scroll positions (since calling focus() can scroll the
page too). |
35 window.scrollTo(0, 0); | 30 window.scrollTo(0, 0); |
36 outerContainer.scrollTop = 0; | 31 container.scrollTop = 0; |
37 innerContainer.scrollTop = 0; | |
38 shouldBe("window.pageYOffset", "0"); | 32 shouldBe("window.pageYOffset", "0"); |
39 shouldBe("outerContainer.scrollTop", "0"); | 33 shouldBe("container.scrollTop", "0"); |
40 shouldBe("innerContainer.scrollTop", "0"); | 34 shouldBeGreaterThanOrEqual("target.getBoundingClientRect().top", "5000"); |
41 shouldBeGreaterThanOrEqual("target.getBoundingClientRect().top", "15000"); | |
42 | 35 |
43 // Scroll to make target visible. | 36 // Scroll to make target visible. |
44 if (window.accessibilityController) | 37 if (window.accessibilityController) |
45 targetAccessibleObject.scrollToMakeVisible(); | 38 targetAccessibleObject.scrollToMakeVisible(); |
46 | 39 |
47 // Instead of testing the exact scroll offsets of the two containers, just t
est that | 40 // Instead of testing the exact scroll offsets of the two containers, just t
est that |
48 // the new absolute position of the target is on-screen. | 41 // the new absolute position of the target is on-screen. |
49 shouldBeGreaterThanOrEqual("window.innerHeight", "target.getBoundingClientRe
ct().bottom"); | 42 shouldBeGreaterThanOrEqual("window.innerHeight", "target.getBoundingClientRe
ct().bottom"); |
50 | 43 |
51 finishJSTest(); | 44 finishJSTest(); |
52 } | 45 } |
53 | 46 |
54 runTest(); | 47 runTest(); |
55 | 48 |
56 </script> | 49 </script> |
57 | 50 |
58 </body> | 51 </body> |
59 </html> | 52 </html> |
OLD | NEW |