summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_revert.js
blob: b68ad0ff9159a1ecd1c6d4059252442e54760537 (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
// Test reverting the urlbar value with ESC after a tab switch.

add_task(async function () {
  registerCleanupFunction(PlacesUtils.history.clear);
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: "http://example.com",
    },
    async function (browser) {
      let originalValue = gURLBar.value;
      let tab = gBrowser.selectedTab;
      info("Put a typed value.");
      gBrowser.userTypedValue = "foobar";
      info("Switch tabs.");
      gBrowser.selectedTab = gBrowser.tabs[0];
      gBrowser.selectedTab = tab;
      Assert.equal(
        gURLBar.value,
        "foobar",
        "location bar displays typed value"
      );

      gURLBar.focus();
      EventUtils.synthesizeKey("KEY_Escape");
      Assert.equal(
        gURLBar.value,
        originalValue,
        "ESC reverted the location bar value"
      );
    }
  );
});