|
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="../events.js"></script> |
|
18 <script type="application/javascript" |
|
19 src="../role.js"></script> |
|
20 <script type="application/javascript" |
|
21 src="../states.js"></script> |
|
22 |
|
23 <script type="application/javascript"> |
|
24 function openCloseDialog(aID) |
|
25 { |
|
26 this.eventSeq = [ |
|
27 new focusChecker(getNode(aID)) |
|
28 ]; |
|
29 |
|
30 this.invoke = function openCloseDialog_invoke() |
|
31 { |
|
32 var wnd = window.open("focus.html"); |
|
33 wnd.close(); |
|
34 } |
|
35 |
|
36 this.getID = function openCloseDialog_getID() |
|
37 { |
|
38 return "Open close dialog while focus on " + prettyName(aID); |
|
39 } |
|
40 } |
|
41 |
|
42 var gDialogWnd = null; |
|
43 function getDialogDocument() |
|
44 { |
|
45 return gDialogWnd.document; |
|
46 } |
|
47 |
|
48 function openDialog(aID) |
|
49 { |
|
50 this.eventSeq = [ |
|
51 new focusChecker(getDialogDocument) |
|
52 ]; |
|
53 |
|
54 this.invoke = function openDialog_invoke() |
|
55 { |
|
56 gDialogWnd = window.open("focus.html"); |
|
57 } |
|
58 |
|
59 this.getID = function openDialog_getID() |
|
60 { |
|
61 return "Open dialog while focus on " + prettyName(aID); |
|
62 } |
|
63 } |
|
64 |
|
65 function closeDialog(aID) |
|
66 { |
|
67 this.eventSeq = [ |
|
68 new focusChecker(aID) |
|
69 ]; |
|
70 |
|
71 this.invoke = function closeDialog_invoke() |
|
72 { |
|
73 gDialogWnd.close(); |
|
74 } |
|
75 |
|
76 this.getID = function closeDialog_getID() |
|
77 { |
|
78 return "Close dialog while focus on " + prettyName(aID); |
|
79 } |
|
80 } |
|
81 |
|
82 function showNFocusAlertDialog() |
|
83 { |
|
84 this.ID = "alertdialog"; |
|
85 this.DOMNode = getNode(this.ID); |
|
86 |
|
87 this.invoke = function showNFocusAlertDialog_invoke() |
|
88 { |
|
89 document.getElementById(this.ID).style.display = 'block'; |
|
90 document.getElementById(this.ID).focus(); |
|
91 } |
|
92 |
|
93 this.eventSeq = [ |
|
94 new invokerChecker(EVENT_SHOW, this.DOMNode), |
|
95 new focusChecker(this.DOMNode) |
|
96 ]; |
|
97 |
|
98 this.getID = function showNFocusAlertDialog_getID() |
|
99 { |
|
100 return "Show and focus alert dialog " + prettyName(this.ID); |
|
101 } |
|
102 } |
|
103 |
|
104 /** |
|
105 * Do tests. |
|
106 */ |
|
107 |
|
108 //gA11yEventDumpID = "eventdump"; // debug stuff |
|
109 //gA11yEventDumpToConsole = true; |
|
110 |
|
111 var gQueue = null; |
|
112 |
|
113 function doTests() |
|
114 { |
|
115 gQueue = new eventQueue(EVENT_FOCUS); |
|
116 |
|
117 gQueue.push(new synthFocus("button")); |
|
118 gQueue.push(new openDialog("button")); |
|
119 gQueue.push(new closeDialog("button")); |
|
120 |
|
121 var frameNode = getNode("editabledoc"); |
|
122 gQueue.push(new synthFocusOnFrame(frameNode)); |
|
123 gQueue.push(new openCloseDialog(frameNode.contentDocument)); |
|
124 |
|
125 gQueue.push(new showNFocusAlertDialog()); |
|
126 |
|
127 gQueue.invoke(); // Will call SimpleTest.finish(); |
|
128 } |
|
129 |
|
130 SimpleTest.waitForExplicitFinish(); |
|
131 addA11yLoadEvent(doTests); |
|
132 </script> |
|
133 </head> |
|
134 |
|
135 <body> |
|
136 |
|
137 <a target="_blank" |
|
138 href="https://bugzilla.mozilla.org/show_bug.cgi?id=551679" |
|
139 title="focus is not fired for focused document when switching between windows"> |
|
140 Mozilla Bug 551679 |
|
141 </a> |
|
142 <a target="_blank" |
|
143 href="https://bugzilla.mozilla.org/show_bug.cgi?id=580464" |
|
144 title="Accessible focus incorrect after JS focus() but correct after switching apps or using menu bar"> |
|
145 Mozilla Bug 580464 |
|
146 </a> |
|
147 <p id="display"></p> |
|
148 <div id="content" style="display: none"></div> |
|
149 <pre id="test"> |
|
150 </pre> |
|
151 |
|
152 <button id="button">button</button> |
|
153 <iframe id="editabledoc" src="focus.html"></iframe> |
|
154 |
|
155 <div id="alertdialog" style="display: none" tabindex="-1" role="alertdialog" aria-labelledby="title2" aria-describedby="desc2"> |
|
156 <div id="title2">Blah blah</div> |
|
157 <div id="desc2">Woof woof woof.</div> |
|
158 <button>Close</button> |
|
159 </div> |
|
160 |
|
161 |
|
162 <div id="eventdump"></div> |
|
163 </body> |
|
164 </html> |