summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_focusonkeydown.js
blob: 9cf1f113f5a9919c3711e425b1e9750590515b48 (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
add_task(async function () {
  let keyUps = 0;

  await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "data:text/html,<body>"
  );

  gURLBar.focus();

  window.addEventListener(
    "keyup",
    function (event) {
      if (event.originalTarget == gURLBar.inputField) {
        keyUps++;
      }
    },
    { capture: true, once: true }
  );

  gURLBar.addEventListener(
    "keydown",
    function (event) {
      gBrowser.selectedBrowser.focus();
    },
    { capture: true, once: true }
  );

  EventUtils.sendString("v");

  is(keyUps, 1, "Key up fired at url bar");

  gBrowser.removeCurrentTab();
});