tor-browser

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

browser_aboutCertError_offlineSupport.js (2005B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const BAD_CERT_PAGE = "https://expired.example.com";
      7 const DUMMY_SUPPORT_BASE_PATH = "/1/firefox/fxVersion/OSVersion/language/";
      8 const DUMMY_SUPPORT_URL = BAD_CERT_PAGE + DUMMY_SUPPORT_BASE_PATH;
      9 const OFFLINE_SUPPORT_PAGE =
     10  "chrome://global/content/neterror/supportpages/time-errors.html";
     11 
     12 add_setup(async function () {
     13  await SpecialPowers.pushPrefEnv({
     14    set: [
     15      ["test.wait300msAfterTabSwitch", true],
     16      ["security.certerrors.felt-privacy-v1", false],
     17    ],
     18  });
     19 });
     20 
     21 add_task(async function testOfflineSupportPage() {
     22  // Cache the original value of app.support.baseURL pref to reset later
     23  let originalBaseURL = Services.prefs.getCharPref("app.support.baseURL");
     24 
     25  Services.prefs.setCharPref("app.support.baseURL", DUMMY_SUPPORT_URL);
     26  let errorTab = await openErrorPage(BAD_CERT_PAGE);
     27 
     28  let offlineSupportPromise = BrowserTestUtils.waitForNewTab(
     29    gBrowser,
     30    DUMMY_SUPPORT_URL + "time-errors"
     31  );
     32  await SpecialPowers.spawn(
     33    errorTab.linkedBrowser,
     34    [DUMMY_SUPPORT_URL],
     35    async expectedURL => {
     36      let doc = content.document;
     37 
     38      let learnMoreLink = doc.getElementById("learnMoreLink");
     39      let supportPageURL = learnMoreLink.getAttribute("href");
     40      Assert.equal(
     41        supportPageURL,
     42        expectedURL + "time-errors",
     43        "Correct support page URL has been set"
     44      );
     45      await EventUtils.synthesizeMouseAtCenter(learnMoreLink, {}, content);
     46    }
     47  );
     48  let offlineSupportTab = await offlineSupportPromise;
     49  await BrowserTestUtils.browserLoaded(
     50    gBrowser.selectedBrowser,
     51    false,
     52    OFFLINE_SUPPORT_PAGE
     53  );
     54 
     55  // Reset this pref instead of clearing it to maintain globally set
     56  // custom value for testing purposes.
     57  Services.prefs.setCharPref("app.support.baseURL", originalBaseURL);
     58 
     59  await BrowserTestUtils.removeTab(offlineSupportTab);
     60  await BrowserTestUtils.removeTab(errorTab);
     61 });