summaryrefslogtreecommitdiff
path: root/browser/base/content/test/urlbar/browser_urlbarRevert.js
blob: 0ce3c8fac88ecbb5f84f0b7ee5b1c72936ef722d (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
35
36
37
var tab = null;

function test() {
  waitForExplicitFinish();

  let pageLoaded = {
    onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
      if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
          aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
        gBrowser.removeProgressListener(this);
        executeSoon(checkURLBarRevert);
      }
    }
  }

  gBrowser.addProgressListener(pageLoaded);
  tab = gBrowser.addTab("http://example.com");
  gBrowser.selectedTab = tab;
}

function checkURLBarRevert() {
  let originalValue = gURLBar.value;

  gBrowser.userTypedValue = "foobar";
  gBrowser.selectedTab = gBrowser.tabs[0];
  gBrowser.selectedTab = tab;
  is(gURLBar.value, "foobar", "location bar displays typed value");

  gURLBar.focus();

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

  is(gURLBar.value, originalValue, "ESC reverted the location bar value");

  gBrowser.removeTab(tab);
  finish();
}