4 <script src=
"../../resources/js-test.js"></script>
7 <a href=
"#fragment1" id=
"link1" tabindex=
"0">link1
</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>
13 <div id=
"fragment1" name=
"fragment1" tabindex=
"0">fragment1
</div>
14 <div id=
"fragment2" name=
"fragment2">fragment2
</div>
16 description("This tests that if an in-page link is activated, focus control is transferred to the fragment if possible.");
18 var link1
= document
.getElementById("link1");
20 debug("Verify that the focus is on the link.");
21 shouldBe("document.activeElement", "link1");
24 debug("Click the link and verify that focus has moved to the fragment.");
25 shouldBe("document.activeElement", "document.getElementById('fragment1')");
27 debug("Move focus back to the link and verify.");
29 shouldBe("document.activeElement", "link1");
31 if (window
.testRunner
) {
32 debug("Send an enter key event which should also trigger focus to move to the fragment.");
33 eventSender
.keyDown("\r");
34 shouldBe("document.activeElement", "document.getElementById('fragment1')");
37 debug("Activate a link that does not have a focusable fragment and verify that the currently focused element is unfocused.");
38 var link2
= document
.getElementById("link2");
40 shouldBe("document.activeElement", "link2");
42 shouldBe("document.activeElement", "document.body");
44 debug("Activate a link that does not refer to an existing fragment and verify that the currently focused element remains focused.");
45 var link3
= document
.getElementById("link3");
47 shouldBe("document.activeElement", "link3");
49 shouldBe("document.activeElement", "link3");
51 debug("Activate a link to #top and verify that the link remains focused");
52 var link4
= document
.getElementById("link4");
54 shouldBe("document.activeElement", "link4");
56 shouldBe("document.activeElement", "link4");
58 debug("Activate a link to # and verify that the link remains focused");
59 var link5
= document
.getElementById("link5");
61 shouldBe("document.activeElement", "link5");
63 shouldBe("document.activeElement", "link5");
65 var successfullyParsed
= true;