forked from mirrors/gecko-dev
Bug 1643651 - Add actions to support DOH CFR r=nhnt11,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D78491
This commit is contained in:
parent
c2f58a5a8d
commit
f58c7a2553
7 changed files with 125 additions and 2 deletions
|
|
@ -542,6 +542,53 @@ const CFR_MESSAGES = [
|
|||
frequency: { lifetime: 3 },
|
||||
trigger: { id: "frequentVisits", params: PINNED_TABS_TARGET_SITES },
|
||||
},
|
||||
{
|
||||
id: "DOH_ROLLOUT_CONFIRMATION",
|
||||
targeting: `
|
||||
"doh-rollout.enabled"|preferenceValue &&
|
||||
!"doh-rollout.disable-heuristics"|preferenceValue &&
|
||||
!"doh-rollout.skipHeuristicsCheck"|preferenceValue &&
|
||||
!"doh-rollout.doorhanger-decision"|preferenceValue
|
||||
`,
|
||||
template: "cfr_doorhanger",
|
||||
content: {
|
||||
skip_address_bar_notifier: true,
|
||||
anchor_id: "PanelUI-menu-button",
|
||||
layout: "icon_and_message",
|
||||
text: { string_id: "cfr-doorhanger-doh-body" },
|
||||
icon: "chrome://browser/skin/connection-secure.svg",
|
||||
buttons: {
|
||||
secondary: [
|
||||
{
|
||||
label: { string_id: "cfr-doorhanger-doh-secondary-button" },
|
||||
action: {
|
||||
type: "DISABLE_DOH",
|
||||
},
|
||||
},
|
||||
],
|
||||
primary: {
|
||||
label: { string_id: "cfr-doorhanger-doh-primary-button" },
|
||||
action: {
|
||||
type: "ACCEPT_DOH",
|
||||
},
|
||||
},
|
||||
},
|
||||
bucket_id: "DOH_ROLLOUT_CONFIRMATION",
|
||||
heading_text: { string_id: "cfr-doorhanger-doh-header" },
|
||||
info_icon: {
|
||||
label: {
|
||||
string_id: "cfr-doorhanger-extension-sumo-link",
|
||||
},
|
||||
sumo_path: "extensionrecommendations",
|
||||
},
|
||||
notification_text: "Message from Firefox",
|
||||
category: "cfrFeatures",
|
||||
},
|
||||
trigger: {
|
||||
id: "openURL",
|
||||
patterns: ["*://*/*"],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "SAVE_LOGIN",
|
||||
frequency: {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ const REGULAR_IDS = [
|
|||
];
|
||||
|
||||
describe("CFRMessageProvider", () => {
|
||||
it("should have a total of 10 messages", () => {
|
||||
assert.lengthOf(messages, 11);
|
||||
it("should have a total of 12 messages", () => {
|
||||
assert.lengthOf(messages, 12);
|
||||
});
|
||||
it("should have one message each for the three regular addons", () => {
|
||||
for (const id of REGULAR_IDS) {
|
||||
|
|
|
|||
|
|
@ -262,3 +262,12 @@ cfr-whatsnew-protections-icon-alt = Shield icon
|
|||
|
||||
cfr-whatsnew-better-pdf-header = Better PDF experience
|
||||
cfr-whatsnew-better-pdf-body = PDF documents now open directly in { -brand-short-name }, keeping your workflow within easy reach.
|
||||
|
||||
## DOH Message
|
||||
|
||||
cfr-doorhanger-doh-body = Your privacy matters. { -brand-short-name } now securely routes your DNS requests whenever possible to a partner service to protect you while you browse.
|
||||
cfr-doorhanger-doh-header = More secure, encrypted DNS lookups
|
||||
cfr-doorhanger-doh-primary-button = OK, Got it
|
||||
.accesskey = O
|
||||
cfr-doorhanger-doh-secondary-button = Disable
|
||||
.accesskey = D
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
const DOH_DOORHANGER_DECISION_PREF = "doh-rollout.doorhanger-decision";
|
||||
const NETWORK_TRR_MODE_PREF = "network.trr.mode";
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
AddonManager: "resource://gre/modules/AddonManager.jsm",
|
||||
|
|
@ -183,6 +185,17 @@ const SpecialMessageActions = {
|
|||
"CRYPTOMINERS_PROTECTION",
|
||||
]);
|
||||
break;
|
||||
case "DISABLE_DOH":
|
||||
Services.prefs.setStringPref(
|
||||
DOH_DOORHANGER_DECISION_PREF,
|
||||
"UIDisabled"
|
||||
);
|
||||
Services.prefs.setIntPref(NETWORK_TRR_MODE_PREF, 5);
|
||||
await this.blockMessageById("DOH_ROLLOUT_CONFIRMATION");
|
||||
break;
|
||||
case "ACCEPT_DOH":
|
||||
Services.prefs.setStringPref(DOH_DOORHANGER_DECISION_PREF, "UIOk");
|
||||
break;
|
||||
case "CANCEL":
|
||||
// A no-op used by CFRs that minimizes the notification but does not
|
||||
// trigger a dismiss or block (it keeps the notification around)
|
||||
|
|
|
|||
|
|
@ -16,3 +16,5 @@ support-files =
|
|||
[browser_sma_show_migration_wizard.js]
|
||||
[browser_sma.js]
|
||||
[browser_sma_docs.js]
|
||||
[browser_sma_accept_doh.js]
|
||||
[browser_sma_disable_doh.js]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
const DOH_DOORHANGER_DECISION_PREF = "doh-rollout.doorhanger-decision";
|
||||
|
||||
add_task(async function test_disable_doh() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[DOH_DOORHANGER_DECISION_PREF, ""]],
|
||||
});
|
||||
await SpecialMessageActions.handleAction({ type: "ACCEPT_DOH" }, gBrowser);
|
||||
Assert.equal(
|
||||
Services.prefs.getStringPref(DOH_DOORHANGER_DECISION_PREF, ""),
|
||||
"UIOk",
|
||||
"Pref should be set on accept"
|
||||
);
|
||||
});
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
const DOH_DOORHANGER_DECISION_PREF = "doh-rollout.doorhanger-decision";
|
||||
const NETWORK_TRR_MODE_PREF = "network.trr.mode";
|
||||
|
||||
add_task(async function test_disable_doh() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[DOH_DOORHANGER_DECISION_PREF, "mochitest"],
|
||||
[NETWORK_TRR_MODE_PREF, 0],
|
||||
],
|
||||
});
|
||||
|
||||
SpecialMessageActions.blockMessageById = messageId =>
|
||||
Assert.equal(
|
||||
messageId,
|
||||
"DOH_ROLLOUT_CONFIRMATION",
|
||||
"Block the correct message"
|
||||
);
|
||||
|
||||
await SpecialMessageActions.handleAction({ type: "DISABLE_DOH" }, gBrowser);
|
||||
|
||||
Assert.equal(
|
||||
Services.prefs.getStringPref(DOH_DOORHANGER_DECISION_PREF, ""),
|
||||
"UIDisabled",
|
||||
"Pref should be set on disabled"
|
||||
);
|
||||
Assert.equal(
|
||||
Services.prefs.getIntPref(NETWORK_TRR_MODE_PREF, 0),
|
||||
5,
|
||||
"Pref should be set on disabled"
|
||||
);
|
||||
});
|
||||
Loading…
Reference in a new issue