Bug 1442990 - Expose a websites.upgradeMixedDisplayContent pref that Web Extensions can toggle. r?aswan
MozReview-Commit-ID: GNfKFnqtSXO
--- a/toolkit/components/extensions/ext-privacy.js
+++ b/toolkit/components/extensions/ext-privacy.js
@@ -211,16 +211,26 @@ ExtensionPreferencesManager.addSetting("
prefs["privacy.trackingprotection.pbmode.enabled"] = false;
break;
}
return prefs;
},
});
+ExtensionPreferencesManager.addSetting("websites.upgradeMixedDisplayContent", {
+ prefNames: [
+ "security.mixed_content.upgrade_display_content",
+ ],
+
+ setCallback(value) {
+ return {[this.prefNames[0]]: value};
+ },
+});
+
this.privacy = class extends ExtensionAPI {
getAPI(context) {
let {extension} = context;
return {
privacy: {
network: {
networkPredictionEnabled: getPrivacyAPI(
extension, "network.networkPredictionEnabled",
@@ -301,14 +311,19 @@ this.privacy = class extends ExtensionAP
() => {
if (Preferences.get("privacy.trackingprotection.enabled")) {
return "always";
} else if (Preferences.get("privacy.trackingprotection.pbmode.enabled")) {
return "private_browsing";
}
return "never";
}),
+ upgradeMixedDisplayContent: getPrivacyAPI(
+ extension, "websites.upgradeMixedDisplayContent",
+ () => {
+ return Preferences.get("security.mixed_content.upgrade_display_content");
+ }),
},
},
};
}
};
--- a/toolkit/components/extensions/schemas/privacy.json
+++ b/toolkit/components/extensions/schemas/privacy.json
@@ -124,12 +124,16 @@
},
"trackingProtectionMode": {
"$ref": "types.Setting",
"description": "Allow users to specify the mode for tracking protection. This setting's value is of type TrackingProtectionModeOption, defaulting to <code>private_browsing_only</code>."
},
"cookieConfig": {
"$ref": "types.Setting",
"description": "Allow users to specify the default settings for allowing cookies, as well as whether all cookies should be created as non-persistent cookies. This setting's value is of type CookieConfig."
+ },
+ "upgradeMixedDisplayContent": {
+ "$ref": "types.Setting",
+ "description": "If enabled, the browser will upgrade any passive mixed content on secure connections."
}
}
}
]
--- a/toolkit/components/extensions/test/xpcshell/test_ext_privacy.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_privacy.js
@@ -242,16 +242,19 @@ add_task(async function test_privacy_oth
},
"websites.firstPartyIsolate": {
"privacy.firstparty.isolate": true,
},
"websites.cookieConfig": {
"network.cookie.cookieBehavior": cookieSvc.BEHAVIOR_ACCEPT,
"network.cookie.lifetimePolicy": cookieSvc.ACCEPT_NORMALLY,
},
+ "websites.upgradeMixedDisplayContent": {
+ "security.mixed_content.upgrade_display_content": true,
+ },
};
async function background() {
browser.test.onMessage.addListener(async (msg, ...args) => {
let data = args[0];
// The second argument is the end of the api name,
// e.g., "network.webRTCIPHandlingPolicy".
let apiObj = args[1].split(".").reduce((o, i) => o[i], browser.privacy);
@@ -474,16 +477,26 @@ add_task(async function test_privacy_oth
"websites.cookieConfig",
{nonPersistentCookies: false},
{
"network.cookie.cookieBehavior": cookieSvc.BEHAVIOR_ACCEPT,
"network.cookie.lifetimePolicy": cookieSvc.ACCEPT_NORMALLY,
},
{behavior: "allow_all", nonPersistentCookies: false},
);
+ await testSetting(
+ "websites.upgradeMixedDisplayContent", false,
+ {
+ "security.mixed_content.upgrade_display_content": false,
+ });
+ await testSetting(
+ "websites.upgradeMixedDisplayContent", true,
+ {
+ "security.mixed_content.upgrade_display_content": true,
+ });
await extension.unload();
await promiseShutdownManager();
});
add_task(async function test_exceptions() {
async function background() {