Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 <html>
3 <head>
4 <title>nsIAccessibleSelectable HTML select testing</title>
6 <link rel="stylesheet" type="text/css"
7 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
9 </style>
11 <script type="application/javascript"
12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
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="../selectable.js"></script>
23 <script type="application/javascript">
25 function doTest()
26 {
27 //////////////////////////////////////////////////////////////////////////
28 // select@size="1" aka combobox
30 var id = "combobox";
31 var combobox = getAccessible(id);
32 var comboboxList = combobox.firstChild;
33 ok(isAccessible(comboboxList, [nsIAccessibleSelectable]),
34 "No selectable accessible for list of " + id);
36 var select = getAccessible(comboboxList, [nsIAccessibleSelectable]);
37 testSelectableSelection(select, [ "cb1_item1" ]);
39 // select 2nd item
40 select.addItemToSelection(1);
41 testSelectableSelection(select, [ "cb1_item2" ], "addItemToSelection(1): ");
43 // unselect 2nd item, 1st item gets selected automatically
44 select.removeItemFromSelection(1);
45 testSelectableSelection(select, [ "cb1_item1" ],
46 "removeItemFromSelection(1): ");
48 // doesn't change selection
49 is(select.selectAll(), false,
50 "No way to select all items in combobox '" + id + "'");
51 testSelectableSelection(select, [ "cb1_item1" ], "selectAll: ");
53 // doesn't change selection
54 select.unselectAll();
55 testSelectableSelection(select, [ "cb1_item1" ], "unselectAll: ");
57 //////////////////////////////////////////////////////////////////////////
58 // select@size="1" with optgroups
60 id = "combobox2";
61 combobox = getAccessible(id);
62 comboboxList = combobox.firstChild;
63 ok(isAccessible(comboboxList, [nsIAccessibleSelectable]),
64 "No selectable accessible for list of " + id);
66 select = getAccessible(comboboxList, [nsIAccessibleSelectable]);
67 testSelectableSelection(select, [ "cb2_item1" ]);
69 select.addItemToSelection(1);
70 testSelectableSelection(select, [ "cb2_item2" ]);
72 select.removeItemFromSelection(1);
73 testSelectableSelection(select, [ "cb2_item1" ]);
75 is(select.selectAll(), false,
76 "No way to select all items in combobox " + id + "'");
77 testSelectableSelection(select, [ "cb2_item1" ]);
79 select.unselectAll();
80 testSelectableSelection(select, [ "cb2_item1" ]);
82 //////////////////////////////////////////////////////////////////////////
83 // select@size="4" aka single selectable listbox
85 var id = "listbox";
86 ok(isAccessible(id, [nsIAccessibleSelectable]),
87 "No selectable accessible for " + id);
89 select = getAccessible(id, [nsIAccessibleSelectable]);
90 testSelectableSelection(select, [ ]);
92 // select 2nd item
93 select.addItemToSelection(1);
94 testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelection(1): ");
96 // unselect 2nd item, 1st item gets selected automatically
97 select.removeItemFromSelection(1);
98 testSelectableSelection(select, [ ],
99 "removeItemFromSelection(1): ");
101 // doesn't change selection
102 is(select.selectAll(), false,
103 "No way to select all items in single selectable listbox '" + id + "'");
104 testSelectableSelection(select, [ ], "selectAll: ");
106 // doesn't change selection
107 select.unselectAll();
108 testSelectableSelection(select, [ ], "unselectAll: ");
110 //////////////////////////////////////////////////////////////////////////
111 // select@size="4" with optgroups, single selectable
113 id = "listbox2";
114 ok(isAccessible(id, [nsIAccessibleSelectable]),
115 "No selectable accessible for " + id);
117 select = getAccessible(id, [nsIAccessibleSelectable]);
118 testSelectableSelection(select, [ ]);
120 select.addItemToSelection(1);
121 testSelectableSelection(select, [ "lb2_item2" ]);
123 select.removeItemFromSelection(1);
124 testSelectableSelection(select, [ ]);
126 is(select.selectAll(), false,
127 "No way to select all items in single selectable listbox " + id + "'");
128 testSelectableSelection(select, [ ]);
130 select.unselectAll();
131 testSelectableSelection(select, [ ]);
133 //////////////////////////////////////////////////////////////////////////
134 // select@size="4" multiselect aka listbox
136 id = "listbox3";
137 ok(isAccessible(id, [nsIAccessibleSelectable]),
138 "No selectable accessible for " + id);
140 select = getAccessible(id, [nsIAccessibleSelectable]);
141 testSelectableSelection(select, [ ]);
143 select.addItemToSelection(0);
144 testSelectableSelection(select, [ "lb3_item1" ], "addItemToSelection: ");
146 select.removeItemFromSelection(0);
147 testSelectableSelection(select, [ ], "removeItemFromSelection: ");
149 is(select.selectAll(), true,
150 "All items in listbox '" + id + "' should be selected");
151 testSelectableSelection(select, [ "lb3_item1", "lb3_item2"],
152 "selectAll: ");
154 select.unselectAll();
155 testSelectableSelection(select, [ ], "unselectAll: ");
157 //////////////////////////////////////////////////////////////////////////
158 // select@size="4" multiselect with optgroups
160 var id = "listbox4";
161 ok(isAccessible(id, [nsIAccessibleSelectable]),
162 "No selectable accessible for " + id);
164 select = getAccessible(id, [nsIAccessibleSelectable]);
165 testSelectableSelection(select, [ ]);
167 select.addItemToSelection(0);
168 testSelectableSelection(select, [ "lb4_item1" ]);
170 select.removeItemFromSelection(0);
171 testSelectableSelection(select, [ ]);
173 is(select.selectAll(), true,
174 "All items in listbox '" + id + "' should be selected");
175 testSelectableSelection(select, [ "lb4_item1", "lb4_item2"]);
177 select.unselectAll();
178 testSelectableSelection(select, [ ]);
180 SimpleTest.finish();
181 }
183 SimpleTest.waitForExplicitFinish();
184 addA11yLoadEvent(doTest);
185 </script>
187 </head>
189 <body>
191 <a target="_blank"
192 href="https://bugzilla.mozilla.org/show_bug.cgi?id=530014"
193 title="ARIA single selectable widget should implement nsIAccessibleSelectable">
194 Mozilla Bug 530014
195 </a><br>
196 <a target="_blank"
197 href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176"
198 title="add pseudo SelectAccessible interface">
199 Mozilla Bug 590176
200 </a><br>
201 <p id="display"></p>
202 <div id="content" style="display: none"></div>
203 <pre id="test">
204 </pre>
206 <select id="combobox">
207 <option id="cb1_item1">option1</option>
208 <option id="cb1_item2">option2</option>
209 </select>
211 <select id="combobox2">
212 <option id="cb2_item1">option1</option>
213 <optgroup>optgroup
214 <option id="cb2_item2">option2</option>
215 </optgroup>
216 </select>
218 <select id="listbox" size="4">
219 <option id="lb1_item1">option1</option>
220 <option id="lb1_item2">option2</option>
221 </select>
223 <select id="listbox2" size="4">
224 <option id="lb2_item1">option1</option>
225 <optgroup>optgroup>
226 <option id="lb2_item2">option2</option>
227 </optgroup>
228 </select>
230 <select id="listbox3" size="4" multiple="true">
231 <option id="lb3_item1">option1</option>
232 <option id="lb3_item2">option2</option>
233 </select>
235 <select id="listbox4" size="4" multiple="true">
236 <option id="lb4_item1">option1</option>
237 <optgroup>optgroup>
238 <option id="lb4_item2">option2</option>
239 </optgroup>
240 </select>
242 </body>
243 </html>