summaryrefslogtreecommitdiffstats
path: root/dom/security/test/mixedcontentblocker/browser_auto_upgrading_identity.js
blob: 7860c06fc29b877ace9b383365182850b076cc05 (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
44
45
46
47
48
49
50
51
52
53
54
55
"use strict";

const TEST_PATH = getRootDirectory(gTestPath).replace(
  "chrome://mochitests/content",
  "https://example.com"
);
const TEST_TOPLEVEL_URI = TEST_PATH + "auto_upgrading_identity.html";

// auto upgrading mixed content should not indicate passive mixed content loaded
add_task(async () => {
  await SpecialPowers.pushPrefEnv({
    set: [["security.mixed_content.upgrade_display_content", true]],
  });
  await BrowserTestUtils.withNewTab(
    TEST_TOPLEVEL_URI,
    async function (browser) {
      await ContentTask.spawn(browser, {}, async function () {
        let testImg = content.document.getElementById("testimage");
        ok(
          testImg.src.includes("auto_upgrading_identity.png"),
          "sanity: correct image is loaded"
        );
      });
      // Ensure the identiy handler does not show mixed content!
      ok(
        !gIdentityHandler._isMixedPassiveContentLoaded,
        "Auto-Upgrading Mixed Content: Identity should note indicate mixed content"
      );
    }
  );
});

// regular mixed content test should indicate passive mixed content loaded
add_task(async () => {
  await SpecialPowers.pushPrefEnv({
    set: [["security.mixed_content.upgrade_display_content", false]],
  });
  await BrowserTestUtils.withNewTab(
    TEST_TOPLEVEL_URI,
    async function (browser) {
      await ContentTask.spawn(browser, {}, async function () {
        let testImg = content.document.getElementById("testimage");
        ok(
          testImg.src.includes("auto_upgrading_identity.png"),
          "sanity: correct image is loaded"
        );
      });
      // Ensure the identiy handler does show mixed content!
      ok(
        gIdentityHandler._isMixedPassiveContentLoaded,
        "Regular Mixed Content: Identity should indicate mixed content"
      );
    }
  );
});