tor-browser

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

browser_bug1757458.js (1448B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 add_task(async function () {
      7  let testPage =
      8    getRootDirectory(gTestPath).replace(
      9      "chrome://mochitests/content",
     10      "view-source:http://example.com"
     11    ) + "redirect_to_blank.sjs";
     12 
     13  let testPage2 = "data:text/html,<div>Second page</div>";
     14  await BrowserTestUtils.withNewTab(
     15    { gBrowser, url: testPage },
     16    async function (browser) {
     17      await ContentTask.spawn(browser, [], async () => {
     18        Assert.equal(
     19          content.document.getElementById("viewsource").localName,
     20          "body",
     21          "view-source document's body should have id='viewsource'."
     22        );
     23        content.document
     24          .getElementById("viewsource")
     25          .setAttribute("onunload", "/* disable bfcache*/");
     26      });
     27 
     28      BrowserTestUtils.startLoadingURIString(browser, testPage2);
     29      await BrowserTestUtils.browserLoaded(browser);
     30 
     31      let pageShownPromise = BrowserTestUtils.waitForContentEvent(
     32        browser,
     33        "pageshow",
     34        true
     35      );
     36      browser.browsingContext.goBack();
     37      await pageShownPromise;
     38 
     39      await ContentTask.spawn(browser, [], async () => {
     40        Assert.equal(
     41          content.document.getElementById("viewsource").localName,
     42          "body",
     43          "view-source document's body should have id='viewsource'."
     44        );
     45      });
     46    }
     47  );
     48 });