tor-browser

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

browser_auto_upgrading_identity.js (1812B)


      1 "use strict";
      2 
      3 const TEST_PATH = getRootDirectory(gTestPath).replace(
      4  "chrome://mochitests/content",
      5  "https://example.com"
      6 );
      7 const TEST_TOPLEVEL_URI = TEST_PATH + "auto_upgrading_identity.html";
      8 
      9 // auto upgrading mixed content should not indicate passive mixed content loaded
     10 add_task(async () => {
     11  await SpecialPowers.pushPrefEnv({
     12    set: [["security.mixed_content.upgrade_display_content", true]],
     13  });
     14  await BrowserTestUtils.withNewTab(
     15    TEST_TOPLEVEL_URI,
     16    async function (browser) {
     17      await ContentTask.spawn(browser, {}, async function () {
     18        let testImg = content.document.getElementById("testimage");
     19        ok(
     20          testImg.src.includes("auto_upgrading_identity.png"),
     21          "sanity: correct image is loaded"
     22        );
     23      });
     24      // Ensure the identiy handler does not show mixed content!
     25      ok(
     26        !gIdentityHandler._isMixedPassiveContentLoaded,
     27        "Auto-Upgrading Mixed Content: Identity should note indicate mixed content"
     28      );
     29    }
     30  );
     31 });
     32 
     33 // regular mixed content test should indicate passive mixed content loaded
     34 add_task(async () => {
     35  await SpecialPowers.pushPrefEnv({
     36    set: [["security.mixed_content.upgrade_display_content", false]],
     37  });
     38  await BrowserTestUtils.withNewTab(
     39    TEST_TOPLEVEL_URI,
     40    async function (browser) {
     41      await ContentTask.spawn(browser, {}, async function () {
     42        let testImg = content.document.getElementById("testimage");
     43        ok(
     44          testImg.src.includes("auto_upgrading_identity.png"),
     45          "sanity: correct image is loaded"
     46        );
     47      });
     48      // Ensure the identiy handler does show mixed content!
     49      ok(
     50        gIdentityHandler._isMixedPassiveContentLoaded,
     51        "Regular Mixed Content: Identity should indicate mixed content"
     52      );
     53    }
     54  );
     55 });