tor-browser

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

browser_no_mcb_for_onions.js (1495B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // The test loads a HTTPS web page with active content from HTTP .onion URLs
      5 // and makes sure that the mixed content flags on the docshell are not set.
      6 //
      7 // Note that the URLs referenced within the test page intentionally use the
      8 // unassigned port 8 because we don't want to actually load anything, we just
      9 // want to check that the URLs are not blocked.
     10 
     11 const TEST_URL =
     12  getRootDirectory(gTestPath).replace(
     13    "chrome://mochitests/content",
     14    "https://example.com"
     15  ) + "test_no_mcb_for_onions.html";
     16 
     17 const PREF_BLOCK_DISPLAY = "security.mixed_content.block_display_content";
     18 const PREF_BLOCK_ACTIVE = "security.mixed_content.block_active_content";
     19 const PREF_ONION_ALLOWLIST = "dom.securecontext.allowlist_onions";
     20 
     21 add_task(async function allowOnionMixedContent() {
     22  registerCleanupFunction(function () {
     23    gBrowser.removeCurrentTab();
     24  });
     25 
     26  await SpecialPowers.pushPrefEnv({ set: [[PREF_BLOCK_DISPLAY, true]] });
     27  await SpecialPowers.pushPrefEnv({ set: [[PREF_BLOCK_ACTIVE, true]] });
     28  await SpecialPowers.pushPrefEnv({ set: [[PREF_ONION_ALLOWLIST, true]] });
     29 
     30  const tab = await BrowserTestUtils.openNewForegroundTab(
     31    gBrowser,
     32    TEST_URL
     33  ).catch(console.error);
     34  const browser = gBrowser.getBrowserForTab(tab);
     35 
     36  await assertMixedContentBlockingState(browser, {
     37    activeBlocked: false,
     38    activeLoaded: false,
     39    passiveLoaded: false,
     40  });
     41 });