summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_focusonkeydown.js
blob: 53919bc1b3b39c98f7dbacd97ca504af7b38be90 (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 () {
      gBrowser.selectedBrowser.focus();
    },
    { capture: true, once: true }
  );

  EventUtils.sendString("v");

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

  gBrowser.removeCurrentTab();
});