accessible/tests/mochitest/events/test_focus_general.html

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:1689ded000ba
1 <html>
2
3 <head>
4 <title>Accessible focus testing</title>
5
6 <link rel="stylesheet" type="text/css"
7 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
8
9 <script type="application/javascript"
10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <script type="application/javascript"
12 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
13
14 <script type="application/javascript"
15 src="../common.js"></script>
16 <script type="application/javascript"
17 src="../role.js"></script>
18 <script type="application/javascript"
19 src="../events.js"></script>
20 <script type="application/javascript"
21 src="../states.js"></script>
22
23 <script type="application/javascript">
24 function focusElmWhileSubdocIsFocused(aID)
25 {
26 this.DOMNode = getNode(aID);
27
28 this.invoke = function focusElmWhileSubdocIsFocused_invoke()
29 {
30 this.DOMNode.focus();
31 }
32
33 this.eventSeq = [
34 new focusChecker(this.DOMNode)
35 ];
36
37 this.unexpectedEventSeq = [
38 new invokerChecker(EVENT_FOCUS, this.DOMNode.ownerDocument)
39 ];
40
41 this.getID = function focusElmWhileSubdocIsFocused_getID()
42 {
43 return "Focus element while subdocument is focused " + prettyName(aID);
44 }
45 }
46
47 function imageMapChecker(aID)
48 {
49 var node = getNode(aID);
50 this.type = EVENT_FOCUS;
51 this.match = function imageMapChecker_match(aEvent)
52 {
53 return aEvent.DOMNode == node;
54 }
55 }
56
57 function topMenuChecker()
58 {
59 this.type = EVENT_FOCUS;
60 this.match = function topMenuChecker_match(aEvent)
61 {
62 return aEvent.accessible.role == ROLE_PARENT_MENUITEM;
63 }
64 }
65
66 function contextMenuChecker()
67 {
68 this.type = EVENT_MENUPOPUP_START;
69 this.match = function contextMenuChecker_match(aEvent)
70 {
71 return aEvent.accessible.role == ROLE_MENUPOPUP;
72 }
73 }
74
75 function focusContextMenuItemChecker()
76 {
77 this.__proto__ = new focusChecker();
78
79 this.match = function focusContextMenuItemChecker_match(aEvent)
80 {
81 return aEvent.accessible.role == ROLE_MENUITEM;
82 }
83 }
84
85 /**
86 * Do tests.
87 */
88
89 //gA11yEventDumpID = "eventdump"; // debug stuff
90 //gA11yEventDumpToConsole = true;
91
92 var gQueue = null;
93
94 function doTests()
95 {
96 var frameDoc = document.getElementById("iframe").contentDocument;
97
98 var editableDoc = document.getElementById('editabledoc').contentDocument;
99 editableDoc.designMode = 'on';
100
101 gQueue = new eventQueue();
102
103 gQueue.push(new synthFocus("editablearea"));
104 gQueue.push(new synthFocus("navarea"));
105 gQueue.push(new synthTab("navarea", new focusChecker(frameDoc)));
106 gQueue.push(new focusElmWhileSubdocIsFocused("link"));
107
108 gQueue.push(new synthTab(editableDoc, new focusChecker(editableDoc)));
109 if (WIN || LINUX) {
110 // Alt key is used to active menubar and focus menu item on Windows,
111 // other platforms requires setting a ui.key.menuAccessKeyFocuses
112 // preference.
113 gQueue.push(new toggleTopMenu(editableDoc, new topMenuChecker()));
114 gQueue.push(new toggleTopMenu(editableDoc, new focusChecker(editableDoc)));
115 }
116 gQueue.push(new synthContextMenu(editableDoc, new contextMenuChecker()));
117 gQueue.push(new synthDownKey(editableDoc, new focusContextMenuItemChecker()));
118 gQueue.push(new synthEscapeKey(editableDoc, new focusChecker(editableDoc)));
119 if (SEAMONKEY) {
120 todo(false, "shift tab from editable document fails on (Windows) SeaMonkey! (Bug 718235)");
121 } else {
122 if (LINUX || MAC)
123 todo(false, "shift tab from editable document fails on linux and Mac, bug 746519!");
124 else
125 gQueue.push(new synthShiftTab("link", new focusChecker("link")));
126 } // ! SEAMONKEY
127
128 gQueue.push(new synthFocus("a", new imageMapChecker("a")));
129 gQueue.push(new synthFocus("b", new imageMapChecker("b")));
130
131 gQueue.invoke(); // Will call SimpleTest.finish();
132 }
133
134 SimpleTest.waitForExplicitFinish();
135 addA11yLoadEvent(doTests);
136 </script>
137 </head>
138
139 <body>
140 <a target="_blank"
141 href="https://bugzilla.mozilla.org/show_bug.cgi?id=352220"
142 title="Inconsistent focus events when returning to a document frame">
143 Mozilla Bug 352220
144 </a>
145 <a target="_blank"
146 href="https://bugzilla.mozilla.org/show_bug.cgi?id=550338"
147 title="Broken focus when returning to editable documents from menus">
148 Mozilla Bug 550338
149 </a>
150 <a target="_blank"
151 href="https://bugzilla.mozilla.org/show_bug.cgi?id=673958"
152 title="Rework accessible focus handling">
153 Mozilla Bug 673958
154 </a>
155 <a target="_blank"
156 href="https://bugzilla.mozilla.org/show_bug.cgi?id=961696"
157 title="Accessible object:state-changed:focused events for imagemap links are broken">
158 Mozilla Bug 961696
159 </a>
160 <p id="display"></p>
161 <div id="content" style="display: none"></div>
162 <pre id="test">
163 </pre>
164
165 <div id="editablearea" contentEditable="true">editable area</div>
166 <div id="navarea" tabindex="0">navigable area</div>
167 <iframe id="iframe" src="data:text/html,<html></html>"></iframe>
168 <a id="link" href="">link</a>
169 <iframe id="editabledoc" src="about:blank"></iframe>
170
171 <map name="atoz_map">
172 <area id="a" coords="0,0,13,14" shape="rect">
173 <area id="b" coords="17,0,30,14" shape="rect">
174 </map>
175 <img width="447" height="15" usemap="#atoz_map" src="../letters.gif">
176
177 <div id="eventdump"></div>
178 </body>
179 </html>

mercurial