tor-browser

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

browser_mixedcontent_aboutblocked.js (1457B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 const SECURE_CONTAINER_URL =
      5  "https://example.com/browser/browser/components/safebrowsing/content/test/empty_file.html";
      6 
      7 add_task(async function testNormalBrowsing() {
      8  await SpecialPowers.pushPrefEnv({
      9    set: [["browser.safebrowsing.only_top_level", false]],
     10  });
     11 
     12  await BrowserTestUtils.withNewTab(
     13    SECURE_CONTAINER_URL,
     14    async function (browser) {
     15      // Before we load the phish url, we have to make sure the hard-coded
     16      // black list has been added to the database.
     17      await new Promise(resolve => waitForDBInit(resolve));
     18 
     19      let promise = new Promise(resolve => {
     20        // Register listener before loading phish URL.
     21        let removeFunc = BrowserTestUtils.addContentEventListener(
     22          browser,
     23          "AboutBlockedLoaded",
     24          () => {
     25            removeFunc();
     26            resolve();
     27          },
     28          { wantUntrusted: true }
     29        );
     30      });
     31 
     32      await SpecialPowers.spawn(
     33        browser,
     34        [PHISH_URL],
     35        async function (aPhishUrl) {
     36          // Create an iframe which is going to load a phish url.
     37          let iframe = content.document.createElement("iframe");
     38          iframe.src = aPhishUrl;
     39          content.document.body.appendChild(iframe);
     40        }
     41      );
     42 
     43      await promise;
     44      ok(true, "about:blocked is successfully loaded!");
     45    }
     46  );
     47 });