|
132 | 132 | expectedFocusedElement = priorFocus;
|
133 | 133 | }
|
134 | 134 | assert_true(!!expectedFocusedElement);
|
135 |
| - assert_false(popup.matches(':popup-open')); |
| 135 | + assert_false(popup.matches(':top-layer')); |
136 | 136 |
|
137 | 137 | // Directly show and hide the popup:
|
138 | 138 | priorFocus.focus();
|
|
156 | 156 | assert_equals(document.activeElement, expectedFocusedElement, `${testName} activated by popup.showPopup()`);
|
157 | 157 | assert_equals(popup.popup, 'popup', 'All popups in this test should start as popup=popup');
|
158 | 158 | popup.popup = 'hint';
|
159 |
| - assert_false(popup.matches(':popup-open'), 'Changing the popup type should hide the popup'); |
| 159 | + assert_false(popup.matches(':top-layer'), 'Changing the popup type should hide the popup'); |
160 | 160 | assert_equals(document.activeElement, priorFocus, 'prior element should get focus when the type is changed');
|
161 | 161 | popup.popup = 'popup';
|
162 | 162 |
|
|
165 | 165 | popup.showPopup();
|
166 | 166 | assert_equals(document.activeElement, expectedFocusedElement, `${testName} activated by popup.showPopup()`);
|
167 | 167 | popup.remove();
|
168 |
| - assert_false(popup.matches(':popup-open'), 'Removing the popup should hide it'); |
| 168 | + assert_false(popup.matches(':top-layer'), 'Removing the popup should hide it'); |
169 | 169 | if (!popup.hasAttribute('data-no-focus')) {
|
170 | 170 | assert_not_equals(document.activeElement, priorFocus, 'prior element should *not* get focus when the popup is removed from the document');
|
171 | 171 | }
|
|
177 | 177 | assert_equals(document.activeElement, expectedFocusedElement, `${testName} activated by popup.showPopup()`);
|
178 | 178 | const dialog = document.body.appendChild(document.createElement('dialog'));
|
179 | 179 | dialog.showModal();
|
180 |
| - assert_false(popup.matches(':popup-open'), 'Opening a modal dialog should hide the popup'); |
| 180 | + assert_false(popup.matches(':top-layer'), 'Opening a modal dialog should hide the popup'); |
181 | 181 | assert_not_equals(document.activeElement, priorFocus, 'prior element should *not* get focus when a modal dialog is shown');
|
182 | 182 | dialog.close();
|
183 | 183 | dialog.remove();
|
|
186 | 186 | const button = addInvoker(t, popup);
|
187 | 187 | priorFocus.focus();
|
188 | 188 | button.click();
|
189 |
| - assert_true(popup.matches(':popup-open')); |
| 189 | + assert_true(popup.matches(':top-layer')); |
190 | 190 | assert_equals(document.activeElement, expectedFocusedElement, `${testName} activated by button.click()`);
|
191 | 191 |
|
192 | 192 | // Make sure we can directly focus the (already open) popup:
|
193 | 193 | popup.focus();
|
194 | 194 | assert_equals(document.activeElement, popup.hasAttribute('tabindex') ? popup : expectedFocusedElement, `${testName} directly focus with popup.focus()`);
|
195 | 195 | button.click(); // Button is set to toggle the popup
|
196 |
| - assert_false(popup.matches(':popup-open')); |
| 196 | + assert_false(popup.matches(':top-layer')); |
197 | 197 | assert_equals(document.activeElement, priorFocus, 'prior element should get focus on button-toggled hide');
|
198 | 198 | }, "Popup focus test: " + testName);
|
199 | 199 |
|
200 | 200 | promise_test(async t => {
|
201 | 201 | const priorFocus = addPriorFocus(t);
|
202 |
| - assert_false(popup.matches(':popup-open'), 'popup should start out hidden'); |
| 202 | + assert_false(popup.matches(':top-layer'), 'popup should start out hidden'); |
203 | 203 | let button = addInvoker(t, popup);
|
204 | 204 | assert_equals(button.getAttribute('togglepopup'), popup.id, 'This test assumes the button uses `togglepopup`.');
|
205 | 205 | assert_not_equals(button, priorFocus, 'Stranger things have happened');
|
206 | 206 | assert_false(popup.contains(button), 'Start with a non-contained button');
|
207 | 207 | priorFocus.focus();
|
208 | 208 | assert_equals(document.activeElement, priorFocus);
|
209 | 209 | popup.showPopup();
|
210 |
| - assert_true(popup.matches(':popup-open')); |
| 210 | + assert_true(popup.matches(':top-layer')); |
211 | 211 | await clickOn(button); // This will not light dismiss, but will "toggle" the popup.
|
212 |
| - assert_false(popup.matches(':popup-open')); |
| 212 | + assert_false(popup.matches(':top-layer')); |
213 | 213 | assert_equals(document.activeElement, priorFocus, 'Focus should return to prior focus');
|
214 | 214 |
|
215 | 215 | // Same thing, but the button is contained within the popup
|
|
218 | 218 | popup.appendChild(button);
|
219 | 219 | priorFocus.focus();
|
220 | 220 | popup.showPopup();
|
221 |
| - assert_true(popup.matches(':popup-open')); |
| 221 | + assert_true(popup.matches(':top-layer')); |
222 | 222 | if (!popup.hasAttribute('data-no-focus')) {
|
223 | 223 | assert_not_equals(document.activeElement, priorFocus, 'focus should shift for this element');
|
224 | 224 | }
|
225 | 225 | await clickOn(button);
|
226 |
| - assert_false(popup.matches(':popup-open'), 'clicking button should hide the popup'); |
| 226 | + assert_false(popup.matches(':top-layer'), 'clicking button should hide the popup'); |
227 | 227 | assert_equals(document.activeElement, priorFocus, 'Contained button should return focus to the previously focused element');
|
228 | 228 |
|
229 | 229 | // Same thing, but the button is unrelated (no togglepopup)
|
230 | 230 | button = document.createElement('button');
|
231 | 231 | document.body.appendChild(button);
|
232 | 232 | priorFocus.focus();
|
233 | 233 | popup.showPopup();
|
234 |
| - assert_true(popup.matches(':popup-open')); |
| 234 | + assert_true(popup.matches(':top-layer')); |
235 | 235 | await clickOn(button); // This will light dismiss the popup, focus the prior focus, then focus this button.
|
236 |
| - assert_false(popup.matches(':popup-open'), 'clicking button should hide the popup (via light dismiss)'); |
| 236 | + assert_false(popup.matches(':top-layer'), 'clicking button should hide the popup (via light dismiss)'); |
237 | 237 | assert_equals(document.activeElement, button, 'Focus should go to unrelated button on light dismiss');
|
238 | 238 | }, "Popup button click focus test: " + testName);
|
239 | 239 |
|
|
243 | 243 | return;
|
244 | 244 | }
|
245 | 245 | const priorFocus = addPriorFocus(t);
|
246 |
| - assert_false(popup.matches(':popup-open'), 'popup should start out hidden'); |
| 246 | + assert_false(popup.matches(':top-layer'), 'popup should start out hidden'); |
247 | 247 |
|
248 | 248 | // Move the prior focus out of the document
|
249 | 249 | priorFocus.focus();
|
250 | 250 | popup.showPopup();
|
251 |
| - assert_true(popup.matches(':popup-open')); |
| 251 | + assert_true(popup.matches(':top-layer')); |
252 | 252 | const newFocus = document.activeElement;
|
253 | 253 | assert_not_equals(newFocus, priorFocus, 'focus should shift for this element');
|
254 | 254 | priorFocus.remove();
|
|
260 | 260 | // Move the prior focus inside the (already open) popup
|
261 | 261 | priorFocus.focus();
|
262 | 262 | popup.showPopup();
|
263 |
| - assert_true(popup.matches(':popup-open')); |
| 263 | + assert_true(popup.matches(':top-layer')); |
264 | 264 | assert_false(popup.contains(priorFocus), 'Start with a non-contained prior focus');
|
265 | 265 | popup.appendChild(priorFocus); // Move inside the popup
|
266 | 266 | assert_true(popup.contains(priorFocus));
|
267 |
| - assert_true(popup.matches(':popup-open'), 'popup should stay open'); |
| 267 | + assert_true(popup.matches(':top-layer'), 'popup should stay open'); |
268 | 268 | popup.hidePopup();
|
269 | 269 | assert_not_equals(document.activeElement, priorFocus, 'focused element is display:none inside the popup');
|
270 | 270 | document.body.appendChild(priorFocus); // Put it back
|
|
0 commit comments