fune/browser/base/content/test/forms/browser_selectpopup_toplevel.js
Anna Yeddi 8b33a08d4f Bug 1872903 - Add an exception from a11y_checks for clicks on a web content in Desktop UI mochitests. r=mconley
The `browser/base/content/test/forms/browser_selectpopup_large.js` sends [a click outside on a web content](https://searchfox.org/mozilla-central/rev/762f24e00a9548d80ebba1b985c871ba6d9b829d/browser/base/content/test/forms/browser_selectpopup_large.js#177-182). We do not want to test arbitrary web content, since we do not support remote documents like in-content elements with a11y_checks of browser mochitests at the moment, thus we add an exception from the a11y_checks for this tests via `setEnv` and remove the `fail-if` notation from its test manifest.

The same exception is needed for the following Desktop UI test that is also failing [the `labelRule` of a11y_checks](https://searchfox.org/mozilla-central/rev/0f39860036f9b6339e65d485aeb6b6be73d9dbda/testing/mochitest/tests/SimpleTest/AccessibilityUtils.js#106-107):
- `browser/base/content/test/forms/browser_selectpopup_toplevel.js` - `<select>` element

Differential Revision: https://phabricator.services.mozilla.com/D197606
2024-01-04 19:43:16 +00:00

25 lines
1.1 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/ */
add_task(async function () {
let select = document.createElement("select");
select.appendChild(new Option("abc"));
select.appendChild(new Option("defg"));
registerCleanupFunction(() => select.remove());
document.body.appendChild(select);
let popupShownPromise = BrowserTestUtils.waitForSelectPopupShown(window);
// We intentionally turn off this a11y check, because the following click
// is sent on an arbitrary web content that is not expected to be tested
// by itself with the browser mochitests, therefore this rule check shall
// be ignored by a11y-checks suite.
AccessibilityUtils.setEnv({ labelRule: false });
EventUtils.synthesizeMouseAtCenter(select, {});
AccessibilityUtils.resetEnv();
let popup = await popupShownPromise;
ok(!!popup, "Should've shown the popup");
let items = popup.querySelectorAll("menuitem");
is(items.length, 2, "Should have two options");
is(items[0].textContent, "abc", "First option should be correct");
is(items[1].textContent, "defg", "First option should be correct");
});