summaryrefslogtreecommitdiffstats
path: root/browser/components/safebrowsing/content/test/browser_mixedcontent_aboutblocked.js
blob: 7ee4a8a89d4d21d93d9538bd3aeb99e41db3630e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

const SECURE_CONTAINER_URL =
  "https://example.com/browser/browser/components/safebrowsing/content/test/empty_file.html";

add_task(async function testNormalBrowsing() {
  await BrowserTestUtils.withNewTab(
    SECURE_CONTAINER_URL,
    async function (browser) {
      // Before we load the phish url, we have to make sure the hard-coded
      // black list has been added to the database.
      await new Promise(resolve => waitForDBInit(resolve));

      let promise = new Promise(resolve => {
        // Register listener before loading phish URL.
        let removeFunc = BrowserTestUtils.addContentEventListener(
          browser,
          "AboutBlockedLoaded",
          () => {
            removeFunc();
            resolve();
          },
          { wantUntrusted: true }
        );
      });

      await SpecialPowers.spawn(
        browser,
        [PHISH_URL],
        async function (aPhishUrl) {
          // Create an iframe which is going to load a phish url.
          let iframe = content.document.createElement("iframe");
          iframe.src = aPhishUrl;
          content.document.body.appendChild(iframe);
        }
      );

      await promise;
      ok(true, "about:blocked is successfully loaded!");
    }
  );
});