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 id="container" style="width: 100px; overflow: scroll"> | 9 <div id="container" style="width: 100px; overflow: scroll"> |
10 <div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel
box</div> | 10 <div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel
box</div> |
11 <button id="target">Target</button> | 11 <button id="target1">Target</button> |
| 12 <button id="target2">Target</button> |
| 13 <button id="target3">Target</button> |
12 <div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel
box</div> | 14 <div style="border: 1px solid #000; width: 1000px; height: 5000px;">5000-pixel
box</div> |
13 </div> | 15 </div> |
14 | 16 |
15 <div id="console"></div> | 17 <div id="console"></div> |
16 | 18 |
17 <script> | 19 <script> |
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."); | 20 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."); |
19 | 21 |
20 function runTest() { | 22 function runTest() { |
21 window.container = document.getElementById("container"); | 23 window.container = document.getElementById("container"); |
22 window.target = document.getElementById("target"); | 24 window.target1 = document.getElementById("target1"); |
| 25 window.target2 = document.getElementById("target2"); |
| 26 window.target3 = document.getElementById("target3"); |
23 | 27 |
24 if (window.accessibilityController) { | 28 if (window.accessibilityController) { |
25 target.focus(); | 29 target1.focus(); |
26 var targetAccessibleObject = accessibilityController.focusedElement; | 30 var target1AccessibleObject = accessibilityController.focusedElement; |
| 31 target2.focus(); |
| 32 var target2AccessibleObject = accessibilityController.focusedElement; |
| 33 target3.focus(); |
| 34 var target3AccessibleObject = accessibilityController.focusedElement; |
27 } | 35 } |
28 | 36 |
29 // Reset the initial scroll positions (since calling focus() can scroll the
page too). | 37 // Reset the initial scroll positions (since calling focus() can scroll the
page too). |
30 window.scrollTo(0, 0); | 38 window.scrollTo(0, 0); |
31 container.scrollTop = 0; | 39 container.scrollTop = 0; |
32 shouldBe("window.pageYOffset", "0"); | 40 shouldBe("window.pageYOffset", "0"); |
33 shouldBe("container.scrollTop", "0"); | 41 shouldBe("container.scrollTop", "0"); |
34 shouldBeGreaterThanOrEqual("target.getBoundingClientRect().top", "5000"); | 42 shouldBeGreaterThanOrEqual("target1.getBoundingClientRect().top", "5000"); |
35 | 43 |
36 // Scroll to make target visible. | 44 // Scroll to make the middle target visible. |
37 if (window.accessibilityController) | 45 if (window.accessibilityController) |
38 targetAccessibleObject.scrollToMakeVisible(); | 46 target2AccessibleObject.scrollToMakeVisible(); |
39 | 47 |
40 // Instead of testing the exact scroll offsets of the two containers, just t
est that | 48 // Instead of testing the exact scroll offsets of the two containers, just t
est that |
41 // the new absolute position of the target is on-screen. | 49 // the new absolute position of the target is on-screen. |
42 shouldBeGreaterThanOrEqual("window.innerHeight", "target.getBoundingClientRe
ct().bottom"); | 50 shouldBeGreaterThanOrEqual("window.innerHeight", "target2.getBoundingClientR
ect().bottom"); |
| 51 |
| 52 // Make sure that calling scrollToMakeVisible on target1 and target3 don't r
esult 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"); |
43 | 61 |
44 finishJSTest(); | 62 finishJSTest(); |
45 } | 63 } |
46 | 64 |
47 runTest(); | 65 runTest(); |
48 | 66 |
49 </script> | 67 </script> |
50 | 68 |
51 </body> | 69 </body> |
52 </html> | 70 </html> |
OLD | NEW |