tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_selectpopup_focus.js (1018B)


      1 // Empty select to make sure that we click on the menulist button.
      2 const PAGE = `
      3 <!doctype html>
      4 <select style="padding: 0">
      5  <option></option>
      6 </select>
      7 `;
      8 
      9 function tick() {
     10  return new Promise(r =>
     11    requestAnimationFrame(() => requestAnimationFrame(r))
     12  );
     13 }
     14 
     15 add_setup(async function () {
     16  await SpecialPowers.pushPrefEnv({
     17    set: [["test.wait300msAfterTabSwitch", true]],
     18  });
     19 });
     20 
     21 add_task(async function () {
     22  const url = "data:text/html," + encodeURI(PAGE);
     23  await BrowserTestUtils.withNewTab(
     24    {
     25      gBrowser,
     26      url,
     27    },
     28    async function (browser) {
     29      await openSelectPopup("click");
     30      await SpecialPowers.spawn(browser, [], () => {
     31        is(
     32          content.document.activeElement,
     33          content.document.querySelector("select"),
     34          "Select is the active element"
     35        );
     36        ok(
     37          content.document.querySelector("select").matches(":focus"),
     38          "Select matches :focus"
     39        );
     40      });
     41      await hideSelectPopup();
     42    }
     43  );
     44 });