Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / custom / resources / focus-event-handling.js
blob4c7062016b609f32bc739358426f105d29449415
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: ");
12 if (window.testRunner)
13     testRunner.waitUntilDone();
15 function clearFocusSeen(evt)
17     focusinSeen = "";
18     focusoutSeen = "";
21 function focusinHandler(evt)
23     focusinSeen = evt.target.getAttribute('id');
26 function focusoutHandler(evt)
28     focusoutSeen = evt.target.getAttribute('id');
31 rectElement.setAttribute("onfocusin", "focusinHandler(evt)");
32 rectElement.setAttribute("onfocusout", "focusoutHandler(evt)");
33 gElement.setAttribute("onfocusin", "focusinHandler(evt)");
34 gElement.setAttribute("onfocusout", "focusoutHandler(evt)");
35 useElement.setAttribute("onfocusin", "focusinHandler(evt)");
36 useElement.setAttribute("onfocusout", "focusoutHandler(evt)");
37 useElement2.setAttribute("onfocusin", "focusinHandler(evt)");
38 useElement2.setAttribute("onfocusout", "focusoutHandler(evt)");
39 switchElement.setAttribute("onfocusin", "focusinHandler(evt)");
40 switchElement.setAttribute("onfocusout", "focusoutHandler(evt)");
41 imgElement.setAttribute("onfocusin", "focusinHandler(evt)");
42 imgElement.setAttribute("onfocusout", "focusoutHandler(evt)");
44 function clickAt(x, y)
46     eventSender.mouseMoveTo(x, y);
47     eventSender.mouseDown();
48     eventSender.mouseUp();
51 if (window.eventSender) {
53     // cause focusin and focusout
54     clickAt(50, 50);
55     clickAt(150, 250);
56     shouldBeEqualToString('focusinSeen', 'rect1');
57     shouldBeEqualToString('focusoutSeen', 'rect1');
59     clearFocusSeen();
61     // cause focusin and focusout
62     clickAt(150, 50);
63     clickAt(150, 250);
64     shouldBeEqualToString('focusinSeen', 'g');
65     shouldBeEqualToString('focusoutSeen', 'g');
67     clearFocusSeen();
69     // cause focusin and focusout
70     clickAt(250, 50);
71     clickAt(250, 250);
72     shouldBeEqualToString('focusinSeen', 'use');
73     shouldBeEqualToString('focusoutSeen', 'use');
75     clearFocusSeen();
77     // cause focusin and focusout
78     clickAt(350, 50);
79     clickAt(350, 250);
80     shouldBeEqualToString('focusinSeen', 'usesymbol');
81     shouldBeEqualToString('focusoutSeen', 'usesymbol');
83     clearFocusSeen();
85     // cause focusin and focusout
86     clickAt(50, 150);
87     clickAt(50, 250);
88     shouldBeEqualToString('focusinSeen', 'switch');
89     shouldBeEqualToString('focusoutSeen', 'switch');
91     clearFocusSeen();
93     // cause focusin and focusout
94     clickAt(150, 150);
95     clickAt(150, 250);
96     shouldBeEqualToString('focusinSeen', 'img');
97     shouldBeEqualToString('focusoutSeen', 'img');
99     successfullyParsed = true;
100     successfullyParsed = true;
102     if (window.testRunner)
103         testRunner.notifyDone();
104 } else
105     alert("This test must be run via DRT!");