tor-browser

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

browser_bug554155.js (967B)


      1 add_task(async function test() {
      2  await BrowserTestUtils.withNewTab(
      3    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
      4    { gBrowser, url: "http://example.com" },
      5    async function (browser) {
      6      let numLocationChanges = 0;
      7 
      8      let listener = {
      9        onLocationChange(browser, webProgress, request, uri) {
     10          info("location change: " + (uri && uri.spec));
     11          numLocationChanges++;
     12        },
     13      };
     14 
     15      gBrowser.addTabsProgressListener(listener);
     16 
     17      await SpecialPowers.spawn(browser, [], function () {
     18        // pushState to a new URL (http://example.com/foo").  This should trigger
     19        // exactly one LocationChange event.
     20        content.history.pushState(null, null, "foo");
     21      });
     22 
     23      await Promise.resolve();
     24 
     25      gBrowser.removeTabsProgressListener(listener);
     26      is(
     27        numLocationChanges,
     28        1,
     29        "pushState should cause exactly one LocationChange event."
     30      );
     31    }
     32  );
     33 });