summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/forms/browser_selectpopup_focus.js
blob: 24ff947c505f9d33d062d98591e8f4e22dc14ab8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Empty select to make sure that we click on the menulist button.
const PAGE = `
<!doctype html>
<select style="padding: 0">
  <option></option>
</select>
`;

function tick() {
  return new Promise(r =>
    requestAnimationFrame(() => requestAnimationFrame(r))
  );
}

add_task(async function () {
  const url = "data:text/html," + encodeURI(PAGE);
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url,
    },
    async function (browser) {
      await openSelectPopup("click");
      await SpecialPowers.spawn(browser, [], () => {
        is(
          content.document.activeElement,
          content.document.querySelector("select"),
          "Select is the active element"
        );
        ok(
          content.document.querySelector("select").matches(":focus"),
          "Select matches :focus"
        );
      });
      await hideSelectPopup();
    }
  );
});