tor-browser

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

browser_bug655273.js (1833B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /**
      6 * Test for Bug 655273.  Make sure that after changing the URI via
      7 * history.pushState, the resulting SHEntry has the same title as our old
      8 * SHEntry.
      9 */
     10 
     11 add_task(async function test() {
     12  waitForExplicitFinish();
     13 
     14  await BrowserTestUtils.withNewTab(
     15    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
     16    { gBrowser, url: "http://example.com" },
     17    async function (browser) {
     18      if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
     19        await SpecialPowers.spawn(browser, [], async function () {
     20          let cw = content;
     21          let oldTitle = cw.document.title;
     22          ok(oldTitle, "Content window should initially have a title.");
     23          cw.history.pushState("", "", "new_page");
     24 
     25          let shistory = cw.docShell.QueryInterface(
     26            Ci.nsIWebNavigation
     27          ).sessionHistory;
     28 
     29          is(
     30            shistory.legacySHistory.getEntryAtIndex(shistory.index).title,
     31            oldTitle,
     32            "SHEntry title after pushstate."
     33          );
     34        });
     35 
     36        return;
     37      }
     38 
     39      let bc = browser.browsingContext;
     40      let oldTitle = browser.browsingContext.currentWindowGlobal.documentTitle;
     41      ok(oldTitle, "Content window should initially have a title.");
     42      SpecialPowers.spawn(browser, [], async function () {
     43        content.history.pushState("", "", "new_page");
     44      });
     45 
     46      let shistory = bc.sessionHistory;
     47      await SHListener.waitForHistory(shistory, SHListener.NewEntry);
     48 
     49      is(
     50        shistory.getEntryAtIndex(shistory.index).title,
     51        oldTitle,
     52        "SHEntry title after pushstate."
     53      );
     54    }
     55  );
     56 });