Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / click-anchor-blur-refocus-window.html
blob3bc98d661f0aa36a7c97fe5f00a6bd43afc2deae
1 <!DOCTYPE html>
2 <html>
3 <head>
4 </head>
5 <body>
6 <p>This test ensures that the focus ring is shown on the only anchor after tabbing out and inside the window.</p>
7 <a id="anchor" href="javascript:log('anchor was clicked')">Anchor</a>
8 <input id="input">
9 <pre id="console">
10 </pre>
12 <script>
13 var anchor = document.getElementById('anchor');
14 var input = document.getElementById('input');
15 window.onfocus = function() {
16 log('window was focused');
18 window.onblur = function() {
19 log('window was blurred');
21 anchor.onfocus = function() {
22 log('anchor was focused');
24 anchor.onblur = function() {
25 log('anchor was blurred');
27 input.onfocus = function() {
28 log('input was focused');
30 input.onblur = function() {
31 log('input was blurred');
33 window.onload = function() {
34 if (window.eventSender) {
35 // Click the link.
36 eventSender.mouseMoveTo(anchor.offsetLeft + 2, anchor.offsetTop + 2);
37 eventSender.mouseDown();
38 eventSender.mouseUp();
39 // Shift focus to input element.
40 eventSender.keyDown('\t');
41 internals.setFocused(false);
42 testRunner.overridePreference('WebKitTabToLinksPreferenceKey', true);
43 // Set focus to the anchor.
44 internals.setInitialFocus(false);
45 // Upon focus, the default focus ring should be displayed because the
46 // focus was triggered by the keyboard (tab).
47 internals.setFocused(true);
51 function log(message) {
52 var console = document.getElementById("console");
53 console.textContent += message + '\n';
55 </script>
56 </body>
57 </html>