tor-browser

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

browser_bug1874801.js (1515B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Specifically test https://bugzilla.mozilla.org/show_bug.cgi?id=1874801
      7 
      8 const TAB_URL =
      9  "https://example.com/browser/dom/security/test/https-only/file_bug1874801.html";
     10 
     11 function assertImageLoaded(tab) {
     12  return ContentTask.spawn(tab.linkedBrowser, {}, () => {
     13    const img = content.document.getElementsByTagName("img")[0];
     14 
     15    ok(!!img, "Image tag should exist");
     16    ok(img.complete && img.naturalWidth > 0, "Image should have loaded ");
     17  });
     18 }
     19 
     20 add_task(async function test_bug1874801() {
     21  await SpecialPowers.pushPrefEnv({
     22    set: [
     23      ["security.mixed_content.upgrade_display_content", false],
     24      ["dom.security.https_first", true],
     25      ["dom.security.https_only_mode", true],
     26    ],
     27  });
     28 
     29  // Open Tab
     30  const tabToClose = await BrowserTestUtils.openNewForegroundTab(
     31    gBrowser,
     32    TAB_URL,
     33    true
     34  );
     35 
     36  // Make sure the image was loaded via HTTPS
     37  await assertImageLoaded(tabToClose);
     38 
     39  // Close Tab
     40  const tabClosePromise =
     41    BrowserTestUtils.waitForSessionStoreUpdate(tabToClose);
     42  BrowserTestUtils.removeTab(tabToClose);
     43  await tabClosePromise;
     44 
     45  // Restore Tab
     46  const restoredTabPromise = BrowserTestUtils.waitForNewTab(
     47    gBrowser,
     48    TAB_URL,
     49    true
     50  );
     51  SessionWindowUI.undoCloseTab(window);
     52  const restoredTab = await restoredTabPromise;
     53 
     54  // Make sure the image was loaded via HTTPS
     55  await assertImageLoaded(restoredTab);
     56 });