|
1 <html> |
|
2 |
|
3 <head> |
|
4 <title>Context menu tests</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="../states.js"></script> |
|
20 <script type="application/javascript" |
|
21 src="../events.js"></script> |
|
22 |
|
23 <script type="application/javascript"> |
|
24 //////////////////////////////////////////////////////////////////////////// |
|
25 // Invokers |
|
26 |
|
27 function showContextMenu(aID) |
|
28 { |
|
29 this.DOMNode = getNode(aID); |
|
30 |
|
31 this.eventSeq = [ |
|
32 new invokerChecker(EVENT_MENUPOPUP_START, getContextMenuNode()), |
|
33 ]; |
|
34 |
|
35 this.invoke = function showContextMenu_invoke() |
|
36 { |
|
37 synthesizeMouse(this.DOMNode, 4, 4, { type: "contextmenu", button: 2 }); |
|
38 } |
|
39 |
|
40 this.getID = function showContextMenu_getID() |
|
41 { |
|
42 return "show context menu"; |
|
43 } |
|
44 } |
|
45 |
|
46 function selectMenuItem() |
|
47 { |
|
48 this.eventSeq = [ |
|
49 new invokerChecker(EVENT_FOCUS, getFocusedMenuItem) |
|
50 ]; |
|
51 |
|
52 this.invoke = function selectMenuItem_invoke() |
|
53 { |
|
54 synthesizeKey("VK_DOWN", { }); |
|
55 } |
|
56 |
|
57 this.getID = function selectMenuItem_getID() |
|
58 { |
|
59 return "select first menuitem"; |
|
60 } |
|
61 } |
|
62 |
|
63 function closeContextMenu(aID) |
|
64 { |
|
65 this.eventSeq = [ |
|
66 new invokerChecker(EVENT_MENUPOPUP_END, |
|
67 getAccessible(getContextMenuNode())) |
|
68 ]; |
|
69 |
|
70 this.invoke = function closeContextMenu_invoke() |
|
71 { |
|
72 synthesizeKey("VK_ESCAPE", { }); |
|
73 } |
|
74 |
|
75 this.getID = function closeContextMenu_getID() |
|
76 { |
|
77 return "close context menu"; |
|
78 } |
|
79 } |
|
80 |
|
81 function getContextMenuNode() |
|
82 { |
|
83 return getRootAccessible().DOMDocument. |
|
84 getElementById("contentAreaContextMenu"); |
|
85 } |
|
86 |
|
87 function getFocusedMenuItem() |
|
88 { |
|
89 var menu = getAccessible(getAccessible(getContextMenuNode())); |
|
90 for (var idx = 0; idx < menu.childCount; idx++) { |
|
91 var item = menu.getChildAt(idx); |
|
92 |
|
93 if (hasState(item, STATE_FOCUSED)) |
|
94 return getAccessible(item); |
|
95 } |
|
96 return null; |
|
97 } |
|
98 |
|
99 //////////////////////////////////////////////////////////////////////////// |
|
100 // Do tests |
|
101 |
|
102 var gQueue = null; |
|
103 //gA11yEventDumpID = "eventdump"; // debug stuff |
|
104 //gA11yEventDumpToConsole = true; |
|
105 |
|
106 function doTests() |
|
107 { |
|
108 gQueue = new eventQueue(); |
|
109 |
|
110 gQueue.push(new showContextMenu("input")); |
|
111 gQueue.push(new selectMenuItem()); |
|
112 gQueue.push(new closeContextMenu()); |
|
113 |
|
114 gQueue.invoke(); // Will call SimpleTest.finish(); |
|
115 } |
|
116 |
|
117 SimpleTest.waitForExplicitFinish(); |
|
118 addA11yLoadEvent(doTests); |
|
119 </script> |
|
120 </head> |
|
121 |
|
122 <body> |
|
123 |
|
124 <a target="_blank" |
|
125 href="https://bugzilla.mozilla.org/show_bug.cgi?id=580535" |
|
126 title="Broken accessibility in context menus"> |
|
127 Mozilla Bug 580535 |
|
128 </a><br> |
|
129 |
|
130 <p id="display"></p> |
|
131 <div id="content" style="display: none"></div> |
|
132 <pre id="test"> |
|
133 </pre> |
|
134 |
|
135 <input id="input"> |
|
136 |
|
137 <div id="eventdump"></div> |
|
138 </body> |
|
139 </html> |