summaryrefslogtreecommitdiffstats
path: root/docshell/test/browser/browser_bug554155.js
blob: 56915ac58fdc0ba9ac57605967944a15b23dc679 (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
add_task(async function test() {
  await BrowserTestUtils.withNewTab(
    { gBrowser, url: "http://example.com" },
    async function(browser) {
      let numLocationChanges = 0;

      let listener = {
        onLocationChange(browser, webProgress, request, uri, flags) {
          info("location change: " + (uri && uri.spec));
          numLocationChanges++;
        },
      };

      gBrowser.addTabsProgressListener(listener);

      await SpecialPowers.spawn(browser, [], function() {
        // pushState to a new URL (http://example.com/foo").  This should trigger
        // exactly one LocationChange event.
        content.history.pushState(null, null, "foo");
      });

      await Promise.resolve();

      gBrowser.removeTabsProgressListener(listener);
      is(
        numLocationChanges,
        1,
        "pushState should cause exactly one LocationChange event."
      );
    }
  );
});