OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <a href="#fragment1" id="link1" tabindex="0">link1</a> | 7 <a href="#fragment1" id="link1" tabindex="0">link1</a> |
8 <a href="#fragment2" id="link2" tabindex="0">link2</a> | 8 <a href="#fragment2" id="link2" tabindex="0">link2</a> |
| 9 <a href="#fragment3" id="link3" tabindex="0">link3</a> |
| 10 <a href="#top" id="link4" tabindex="0">link4</a> |
| 11 <a href="#" id="link5" tabindex="0">link5</a> |
9 <br><br> | 12 <br><br> |
10 <div id="fragment1" name="fragment1" tabindex="0">fragment1</div> | 13 <div id="fragment1" name="fragment1" tabindex="0">fragment1</div> |
11 <div id="fragment2" name="fragment2">fragment2</div> | 14 <div id="fragment2" name="fragment2">fragment2</div> |
12 <script> | 15 <script> |
13 description("This tests that if an in-page link is activated, focus cont
rol is transferred to the fragment if possible."); | 16 description("This tests that if an in-page link is activated, focus cont
rol is transferred to the fragment if possible."); |
14 | 17 |
15 var link1 = document.getElementById("link1"); | 18 var link1 = document.getElementById("link1"); |
16 link1.focus(); | 19 link1.focus(); |
17 debug("Verify that the focus is on the link."); | 20 debug("Verify that the focus is on the link."); |
18 shouldBe("document.activeElement", "link1"); | 21 shouldBe("document.activeElement", "link1"); |
19 | 22 |
20 link1.click(); | 23 link1.click(); |
21 debug("Click the link and verify that focus has moved to the fragment.")
; | 24 debug("Click the link and verify that focus has moved to the fragment.")
; |
22 shouldBe("document.activeElement", "document.getElementById('fragment1')
"); | 25 shouldBe("document.activeElement", "document.getElementById('fragment1')
"); |
23 | 26 |
24 debug("Move focus back to the link and verify."); | 27 debug("Move focus back to the link and verify."); |
25 link1.focus(); | 28 link1.focus(); |
26 shouldBe("document.activeElement", "link1"); | 29 shouldBe("document.activeElement", "link1"); |
27 | 30 |
28 if (window.testRunner) { | 31 if (window.testRunner) { |
29 debug("Send an enter key event which should also trigger focus to mo
ve to the fragment."); | 32 debug("Send an enter key event which should also trigger focus to mo
ve to the fragment."); |
30 eventSender.keyDown("\r"); | 33 eventSender.keyDown("\r"); |
31 shouldBe("document.activeElement", "document.getElementById('fragmen
t1')"); | 34 shouldBe("document.activeElement", "document.getElementById('fragmen
t1')"); |
32 } | 35 } |
33 | 36 |
34 debug("Activate a link that does not have a focusable fragment and verif
y focus does not move."); | 37 debug("Activate a link that does not have a focusable fragment and verif
y that the currently focused element is unfocused."); |
35 var link2 = document.getElementById("link2"); | 38 var link2 = document.getElementById("link2"); |
36 link2.focus(); | 39 link2.focus(); |
37 shouldBe("document.activeElement", "link2"); | 40 shouldBe("document.activeElement", "link2"); |
38 link2.click(); | 41 link2.click(); |
39 shouldBe("document.activeElement", "link2"); | 42 shouldBe("document.activeElement", "document.body"); |
| 43 |
| 44 debug("Activate a link that does not refer to an existing fragment and v
erify that the currently focused element remains focused."); |
| 45 var link3 = document.getElementById("link3"); |
| 46 link3.focus(); |
| 47 shouldBe("document.activeElement", "link3"); |
| 48 link3.click(); |
| 49 shouldBe("document.activeElement", "link3"); |
| 50 |
| 51 debug("Activate a link to #top and verify that the link remains focused"
); |
| 52 var link4 = document.getElementById("link4"); |
| 53 link4.focus(); |
| 54 shouldBe("document.activeElement", "link4"); |
| 55 link4.click(); |
| 56 shouldBe("document.activeElement", "link4"); |
| 57 |
| 58 debug("Activate a link to # and verify that the link remains focused"); |
| 59 var link5 = document.getElementById("link5"); |
| 60 link5.focus(); |
| 61 shouldBe("document.activeElement", "link5"); |
| 62 link5.click(); |
| 63 shouldBe("document.activeElement", "link5"); |
40 | 64 |
41 var successfullyParsed = true; | 65 var successfullyParsed = true; |
42 </script> | 66 </script> |
43 </body> | 67 </body> |
44 </html> | 68 </html> |
OLD | NEW |