Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / custom / resources / focus-event-handling-keyboard.js
blobff147a1042a94a083fb6a2078706aa17c9be9908
1 var focusinSeen = "";
2 var focusoutSeen = "";
4 var rectElement = document.getElementById("rect1");
5 var gElement = document.getElementById("g");
6 var useElement = document.getElementById("use");
7 var useElement2 = document.getElementById("usesymbol");
8 var switchElement = document.getElementById("switch");
9 var imgElement = document.getElementById("img");
10 description("Test whether focusin and focusout events are dispatched and seen in the focusin/focusout event handlers when using keyboard: ");
12 if (window.testRunner)
13     testRunner.waitUntilDone();
15 function focusinHandler(evt)
17     focusinSeen = evt.target.getAttribute('id');
20 function focusoutHandler(evt)
22     focusoutSeen = evt.target.getAttribute('id');
25 rectElement.setAttribute("onfocusin", "focusinHandler(evt)");
26 rectElement.setAttribute("onfocusout", "focusoutHandler(evt)");
27 gElement.setAttribute("onfocusin", "focusinHandler(evt)");
28 gElement.setAttribute("onfocusout", "focusoutHandler(evt)");
29 useElement.setAttribute("onfocusin", "focusinHandler(evt)");
30 useElement.setAttribute("onfocusout", "focusoutHandler(evt)");
31 useElement2.setAttribute("onfocusin", "focusinHandler(evt)");
32 useElement2.setAttribute("onfocusout", "focusoutHandler(evt)");
33 switchElement.setAttribute("onfocusin", "focusinHandler(evt)");
34 switchElement.setAttribute("onfocusout", "focusoutHandler(evt)");
35 imgElement.setAttribute("onfocusin", "focusinHandler(evt)");
36 imgElement.setAttribute("onfocusout", "focusoutHandler(evt)");
38 if (window.eventSender) {
40     // cause focusin and focusout
41     eventSender.keyDown('\t');
42     shouldBeEqualToString('focusinSeen', 'rect1');
43     eventSender.keyDown('\t');
44     shouldBeEqualToString('focusinSeen', 'g');
45     shouldBeEqualToString('focusoutSeen', 'rect1');
46     eventSender.keyDown('\t');
47     shouldBeEqualToString('focusinSeen', 'use');
48     shouldBeEqualToString('focusoutSeen', 'g');
49     eventSender.keyDown('\t');
50     shouldBeEqualToString('focusinSeen', 'usesymbol');
51     shouldBeEqualToString('focusoutSeen', 'use');
52     eventSender.keyDown('\t');
53     shouldBeEqualToString('focusinSeen', 'switch');
54     shouldBeEqualToString('focusoutSeen', 'usesymbol');
55     eventSender.keyDown('\t');
56     shouldBeEqualToString('focusinSeen', 'img');
57     shouldBeEqualToString('focusoutSeen', 'switch');
58     eventSender.keyDown('\t');
59     shouldBeEqualToString('focusoutSeen', 'img');
61     successfullyParsed = true;
63     if (window.testRunner)
64         testRunner.notifyDone();
65 } else
66     alert("This test must be run via DRT!");