tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_bug1206879.js (1444B)


      1 add_task(async function () {
      2  let url =
      3    getRootDirectory(gTestPath).replace(
      4      "chrome://mochitests/content/",
      5      // eslint-disable-next-line @microsoft/sdl/no-insecure-url
      6      "http://example.com/"
      7    ) + "file_bug1206879.html";
      8  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url, true);
      9 
     10  let numLocationChanges = await SpecialPowers.spawn(
     11    tab.linkedBrowser,
     12    [],
     13    async function () {
     14      let webprogress = content.docShell.QueryInterface(Ci.nsIWebProgress);
     15      let locationChangeCount = 0;
     16      let listener = {
     17        onLocationChange(aWebProgress, aRequest, aLocation) {
     18          info("onLocationChange: " + aLocation.spec);
     19          locationChangeCount++;
     20          this.resolve();
     21        },
     22        QueryInterface: ChromeUtils.generateQI([
     23          "nsIWebProgressListener",
     24          "nsISupportsWeakReference",
     25        ]),
     26      };
     27      let locationPromise = new Promise(resolve => {
     28        listener.resolve = resolve;
     29      });
     30      webprogress.addProgressListener(
     31        listener,
     32        Ci.nsIWebProgress.NOTIFY_LOCATION
     33      );
     34 
     35      content.frames[0].history.pushState(null, null, "foo");
     36 
     37      await locationPromise;
     38      webprogress.removeProgressListener(listener);
     39 
     40      return locationChangeCount;
     41    }
     42  );
     43 
     44  gBrowser.removeTab(tab);
     45  is(
     46    numLocationChanges,
     47    1,
     48    "pushState with a different URI should cause a LocationChange event."
     49  );
     50 });