summaryrefslogtreecommitdiffstats
path: root/docshell/test/browser/browser_bug1206879.js
blob: 1276f64280092e1d8583424346bde0bfd414dbcb (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
add_task(function*() {
  let url = getRootDirectory(gTestPath) + "file_bug1206879.html";
  let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, url, true);

  let numLocationChanges = 0;

  let listener = {
    onLocationChange: function(browser, wp, request, uri, flags) {
      if (browser != tab.linkedBrowser) {
        return;
      }
      info("onLocationChange: " + uri.spec);
      numLocationChanges++;
      this.resolve();
    }
  };
  let locationPromise = new Promise((resolve, reject) => {
    listener.resolve = resolve;
    gBrowser.addTabsProgressListener(listener);
  });
  yield ContentTask.spawn(tab.linkedBrowser, {}, function() {
    content.frames[0].history.pushState(null, null, "foo");
  });

  yield locationPromise;

  gBrowser.removeTab(tab);
  gBrowser.removeTabsProgressListener(listener);
  is(numLocationChanges, 1,
     "pushState with a different URI should cause a LocationChange event.");
});