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

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

  gURLBar.focus();

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

  gURLBar.addEventListener("keydown", function redirectFocus(event) {
    gURLBar.removeEventListener("keydown", redirectFocus, true);
    gBrowser.selectedBrowser.focus();
  }, true);

  EventUtils.synthesizeKey("v", { });

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

  gBrowser.removeCurrentTab();
});