summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_focusonkeydown.js
blob: 4ba16f1490a028e796fbadeb1b389265ecbcb78d (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();
});