summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_populateAfterPushState.js
blob: 8d383092fe0982a0768eff2aae99814fa107768e (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/* When a user clears the URL bar, and then the page pushes state, we should
 * re-fill the URL bar so it doesn't remain empty indefinitely. See bug 1441039.
 * For normal loads, this happens automatically because a non-same-document state
 * change takes place.
 */
add_task(async function () {
  await BrowserTestUtils.withNewTab(
    TEST_BASE_URL + "dummy_page.html",
    async function (browser) {
      gURLBar.value = "";

      let locationChangePromise = BrowserTestUtils.waitForLocationChange(
        gBrowser,
        TEST_BASE_URL + "dummy_page2.html"
      );
      await SpecialPowers.spawn(browser, [], function () {
        content.history.pushState({}, "Page 2", "dummy_page2.html");
      });
      await locationChangePromise;
      is(
        gURLBar.value,
        TEST_BASE_URL + "dummy_page2.html",
        "Should have updated the URL bar."
      );
    }
  );
});