browser_selectpopup_checked.js (1034B)
1 const PAGE = ` 2 <!doctype html> 3 <select style="width: 600px"> 4 <option>ABC</option> 5 <option selected>DEFG</option> 6 </select> 7 `; 8 9 add_setup(async function () { 10 await SpecialPowers.pushPrefEnv({ 11 set: [["test.wait300msAfterTabSwitch", true]], 12 }); 13 }); 14 15 add_task(async function () { 16 const url = "data:text/html," + encodeURI(PAGE); 17 await BrowserTestUtils.withNewTab( 18 { 19 gBrowser, 20 url, 21 }, 22 async function (browser) { 23 await SpecialPowers.spawn(browser, [], async function () { 24 ok( 25 content.document 26 .querySelector("option[selected]") 27 .matches(":checked"), 28 "Option should be selected" 29 ); 30 }); 31 32 let popup = await openSelectPopup("click"); 33 34 await SpecialPowers.spawn(browser, [], async function () { 35 ok( 36 content.document 37 .querySelector("option[selected]") 38 .matches(":checked"), 39 "Option should still be selected" 40 ); 41 }); 42 43 popup.hidePopup(); 44 } 45 ); 46 });