forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfocus-event-handling.html
102 lines (84 loc) · 3.06 KB
/
focus-event-handling.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<script src="../resources/ui-helper.js"></script>
</head>
<body>
<math style="background-color: green">
<mspace id="space1" width="100px" depth="50px" height="50px"/>
<mrow id="row">
<mspace id="space2" width="100px" depth="50px" height="50px"/>
</mrow>
<mfrac id="fraction">
<mspace width="100px" depth="50px"/>
<mspace width="100px" depth="50px"/>
</mfrac>
<mtext id="text" style="font-size:20px">TEST</mtext>
</math>
<p id="description"></p>
<div id="console"></div>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
var focusSeen = "";
var blurSeen = "";
var spaceElement = document.getElementById("space1");
var rowElement = document.getElementById("row");
var fractionElement = document.getElementById("fraction");
var textElement = document.getElementById("text");
function clearFocusSeen()
{
focusSeen = "";
blurSeen = "";
}
function focusHandler(evt)
{
focusSeen = evt.target.getAttribute('id');
}
function blurHandler(evt)
{
blurSeen = evt.target.getAttribute('id');
}
addEventListener("load", async () => {
description("Test whether focus and blur events are dispatched and seen in the focus/blur event handlers: ");
spaceElement.tabIndex = 0;
spaceElement.addEventListener("focus", focusHandler, false);
spaceElement.addEventListener("blur", blurHandler, false);
rowElement.tabIndex = 0;
rowElement.addEventListener("focus", focusHandler, false);
rowElement.addEventListener("blur", blurHandler, false);
fractionElement.tabIndex = 0;
fractionElement.addEventListener("focus", focusHandler, false);
fractionElement.addEventListener("blur", blurHandler, false);
textElement.tabIndex = 0;
textElement.addEventListener("focus", focusHandler, false);
textElement.addEventListener("blur", blurHandler, false);
// cause focus and blur
await UIHelper.activateAt(50, 50);
await UIHelper.activateAt(150, 250);
shouldBeEqualToString('focusSeen', 'space1');
shouldBeEqualToString('blurSeen', 'space1');
clearFocusSeen();
// cause focus and blur
await UIHelper.activateAt(150, 50);
await UIHelper.activateAt(150, 250);
shouldBeEqualToString('focusSeen', 'row');
shouldBeEqualToString('blurSeen', 'row');
clearFocusSeen();
// cause focus and blur
await UIHelper.activateAt(250, 50);
await UIHelper.activateAt(150, 250);
shouldBeEqualToString('focusSeen', 'fraction');
shouldBeEqualToString('blurSeen', 'fraction');
clearFocusSeen();
// cause focus and blur
await UIHelper.activateAt(350, 50);
await UIHelper.activateAt(150, 250);
shouldBeEqualToString('focusSeen', 'text');
shouldBeEqualToString('blurSeen', 'text');
successfullyParsed = true;
testRunner.notifyDone();
});
</script>
</body>
</html>