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