Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / fragment-activation-focuses-target.html
blob8bf03284dabb23743e7c97ce3db0e15eba3198a2
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
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>
12 <br><br>
13 <div id="fragment1" name="fragment1" tabindex="0">fragment1</div>
14 <div id="fragment2" name="fragment2">fragment2</div>
15 <script>
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");
19 link1.focus();
20 debug("Verify that the focus is on the link.");
21 shouldBe("document.activeElement", "link1");
23 link1.click();
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.");
28 link1.focus();
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");
39 link2.focus();
40 shouldBe("document.activeElement", "link2");
41 link2.click();
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");
46 link3.focus();
47 shouldBe("document.activeElement", "link3");
48 link3.click();
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");
53 link4.focus();
54 shouldBe("document.activeElement", "link4");
55 link4.click();
56 shouldBe("document.activeElement", "link4");
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");
65 var successfullyParsed = true;
66 </script>
67 </body>
68 </html>