summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_userTypedValue.js
blob: 8319b3796297b47127b579af3c678aa5534a9033 (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
38
39
40
41
42
43
44
45
46
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

function test() {
  const URI = TEST_BASE_URL + "file_userTypedValue.html";
  window.browserDOMWindow.openURI(
    makeURI(URI),
    null,
    Ci.nsIBrowserDOMWindow.OPEN_NEWTAB,
    Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL,
    Services.scriptSecurityManager.getSystemPrincipal()
  );

  is(gBrowser.userTypedValue, URI, "userTypedValue matches test URI");
  is(gURLBar.value, URI, "location bar value matches test URI");

  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
  gBrowser.removeCurrentTab({ skipPermitUnload: true });
  is(
    gBrowser.userTypedValue,
    URI,
    "userTypedValue matches test URI after switching tabs"
  );
  is(
    gURLBar.value,
    URI,
    "location bar value matches test URI after switching tabs"
  );

  waitForExplicitFinish();
  BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
    is(
      gBrowser.userTypedValue,
      null,
      "userTypedValue is null as the page has loaded"
    );
    is(
      gURLBar.value,
      URI,
      "location bar value matches test URI as the page has loaded"
    );

    gBrowser.removeCurrentTab({ skipPermitUnload: true });
    finish();
  });
}