зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1783840 - Remove doh-rollout extension stub and migrations r=Gijs
This code was added in Firefox 80. I there have been enough versions so that the majority of profiles have been migrated. This patch removes the doh-rollout stub extension, migration code and tests for the migration. Differential Revision: https://phabricator.services.mozilla.com/D154092
This commit is contained in:
Родитель
c7f9ef977a
Коммит
62cd75e04e
|
@ -20,7 +20,6 @@ const lazy = {};
|
|||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
|
||||
ClientID: "resource://gre/modules/ClientID.jsm",
|
||||
ExtensionStorageIDB: "resource://gre/modules/ExtensionStorageIDB.jsm",
|
||||
DoHConfigController: "resource:///modules/DoHConfig.jsm",
|
||||
Heuristics: "resource:///modules/DoHHeuristics.jsm",
|
||||
Preferences: "resource://gre/modules/Preferences.jsm",
|
||||
|
@ -94,9 +93,6 @@ XPCOMUtils.defineLazyServiceGetter(
|
|||
// Stores whether we've done first-run.
|
||||
const FIRST_RUN_PREF = "doh-rollout.doneFirstRun";
|
||||
|
||||
// Records if the user opted in/out of DoH study by clicking on doorhanger
|
||||
const DOORHANGER_USER_DECISION_PREF = "doh-rollout.doorhanger-decision";
|
||||
|
||||
// Set when we detect that the user set their DoH provider or mode manually.
|
||||
// If set, we don't run heuristics.
|
||||
const DISABLED_PREF = "doh-rollout.disable-heuristics";
|
||||
|
@ -154,10 +150,6 @@ const DoHController = {
|
|||
_heuristicsAreEnabled: false,
|
||||
|
||||
async init() {
|
||||
await this.migrateLocalStoragePrefs();
|
||||
await this.migrateOldTrrMode();
|
||||
await this.migrateNextDNSEndpoint();
|
||||
|
||||
Services.telemetry.setEventRecordingEnabled(
|
||||
HEURISTICS_TELEMETRY_CATEGORY,
|
||||
true
|
||||
|
@ -218,105 +210,6 @@ const DoHController = {
|
|||
return this.resetPromise;
|
||||
},
|
||||
|
||||
async migrateLocalStoragePrefs() {
|
||||
const BALROG_MIGRATION_COMPLETED_PREF = "doh-rollout.balrog-migration-done";
|
||||
const ADDON_ID = "doh-rollout@mozilla.org";
|
||||
|
||||
// Migrate updated local storage item names. If this has already been done once, skip the migration
|
||||
const isMigrated = lazy.Preferences.get(
|
||||
BALROG_MIGRATION_COMPLETED_PREF,
|
||||
false
|
||||
);
|
||||
|
||||
if (isMigrated) {
|
||||
return;
|
||||
}
|
||||
|
||||
let policy = WebExtensionPolicy.getByID(ADDON_ID);
|
||||
if (!policy) {
|
||||
return;
|
||||
}
|
||||
|
||||
const storagePrincipal = lazy.ExtensionStorageIDB.getStoragePrincipal(
|
||||
policy.extension
|
||||
);
|
||||
const idbConn = await lazy.ExtensionStorageIDB.open(storagePrincipal);
|
||||
|
||||
// Previously, the DoH heuristics were bundled as an add-on. Early versions
|
||||
// of this add-on used local storage instead of prefs to persist state. This
|
||||
// function migrates the values that are still relevant to their new pref
|
||||
// counterparts.
|
||||
const legacyLocalStorageKeys = [
|
||||
"doneFirstRun",
|
||||
DOORHANGER_USER_DECISION_PREF,
|
||||
DISABLED_PREF,
|
||||
];
|
||||
|
||||
for (let item of legacyLocalStorageKeys) {
|
||||
let data = await idbConn.get(item);
|
||||
let value = data[item];
|
||||
|
||||
if (data.hasOwnProperty(item)) {
|
||||
let migratedName = item;
|
||||
|
||||
if (!item.startsWith("doh-rollout.")) {
|
||||
migratedName = "doh-rollout." + item;
|
||||
}
|
||||
|
||||
lazy.Preferences.set(migratedName, value);
|
||||
}
|
||||
}
|
||||
|
||||
await idbConn.clear();
|
||||
await idbConn.close();
|
||||
|
||||
// Set pref to skip this function in the future.
|
||||
lazy.Preferences.set(BALROG_MIGRATION_COMPLETED_PREF, true);
|
||||
},
|
||||
|
||||
// Previous versions of the DoH frontend worked by setting network.trr.mode
|
||||
// directly to turn DoH on/off. This makes sure we clear that value and also
|
||||
// the pref we formerly used to track changes to it.
|
||||
async migrateOldTrrMode() {
|
||||
const PREVIOUS_TRR_MODE_PREF = "doh-rollout.previous.trr.mode";
|
||||
|
||||
if (lazy.Preferences.get(PREVIOUS_TRR_MODE_PREF) === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lazy.Preferences.get(NETWORK_TRR_MODE_PREF) !== 5) {
|
||||
lazy.Preferences.reset(NETWORK_TRR_MODE_PREF);
|
||||
}
|
||||
lazy.Preferences.reset(PREVIOUS_TRR_MODE_PREF);
|
||||
},
|
||||
|
||||
async migrateNextDNSEndpoint() {
|
||||
// NextDNS endpoint changed from trr.dns.nextdns.io to firefox.dns.nextdns.io
|
||||
// This migration updates any pref values that might be using the old value
|
||||
// to the new one. We support values that match the exact URL that shipped
|
||||
// in the network.trr.resolvers pref in prior versions of the browser.
|
||||
// The migration is a direct static replacement of the string.
|
||||
const oldURL = "https://trr.dns.nextdns.io/";
|
||||
const newURL = "https://firefox.dns.nextdns.io/";
|
||||
const prefsToMigrate = [
|
||||
"network.trr.resolvers",
|
||||
"network.trr.uri",
|
||||
"network.trr.custom_uri",
|
||||
"doh-rollout.trr-selection.dry-run-result",
|
||||
"doh-rollout.uri",
|
||||
];
|
||||
|
||||
for (let pref of prefsToMigrate) {
|
||||
if (!lazy.Preferences.isSet(pref)) {
|
||||
continue;
|
||||
}
|
||||
lazy.Preferences.set(
|
||||
pref,
|
||||
lazy.Preferences.get(pref).replaceAll(oldURL, newURL)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
// The "maybe" is because there are two cases when we don't enable heuristics:
|
||||
// 1. If we detect that TRR mode or URI have user values, or we previously
|
||||
// detected this (i.e. DISABLED_PREF is true)
|
||||
|
|
|
@ -5,8 +5,6 @@ head = head.js
|
|||
skip-if = socketprocess_networking
|
||||
[browser_dirtyEnable.js]
|
||||
[browser_doorhangerUserReject.js]
|
||||
[browser_localStorageMigration.js]
|
||||
[browser_NextDNSMigration.js]
|
||||
[browser_policyOverride.js]
|
||||
[browser_providerSteering.js]
|
||||
[browser_remoteSettings_newProfile.js]
|
||||
|
@ -14,7 +12,6 @@ skip-if = os == 'win' && bits == 32 # Bug 1713464
|
|||
[browser_remoteSettings_rollout.js]
|
||||
skip-if = os == 'win' && bits == 32 # Bug 1713464
|
||||
[browser_rollback.js]
|
||||
[browser_trrMode_migration.js]
|
||||
[browser_trrSelect.js]
|
||||
[browser_trrSelection_disable.js]
|
||||
[browser_userInterference.js]
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(setup);
|
||||
|
||||
add_task(async function testNextDNSMigration() {
|
||||
let oldURL = "https://trr.dns.nextdns.io/";
|
||||
let newURL = "https://firefox.dns.nextdns.io/";
|
||||
|
||||
let prefChangePromises = [];
|
||||
let prefsToMigrate = {
|
||||
"network.trr.resolvers": `[{ "name": "Other Provider", "url": "https://sometrr.com/query" }, { "name": "NextDNS", "url": "${oldURL}" }]`,
|
||||
"network.trr.uri": oldURL,
|
||||
"network.trr.custom_uri": oldURL,
|
||||
"doh-rollout.trr-selection.dry-run-result": oldURL,
|
||||
"doh-rollout.uri": oldURL,
|
||||
};
|
||||
|
||||
for (let [pref, value] of Object.entries(prefsToMigrate)) {
|
||||
Preferences.set(pref, value);
|
||||
|
||||
prefChangePromises.push(
|
||||
new Promise(resolve => {
|
||||
Preferences.observe(pref, function obs() {
|
||||
Preferences.ignore(pref, obs);
|
||||
resolve();
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
let migrationDone = Promise.all(prefChangePromises);
|
||||
await restartDoHController();
|
||||
await migrationDone;
|
||||
|
||||
for (let [pref, value] of Object.entries(prefsToMigrate)) {
|
||||
is(
|
||||
Preferences.get(pref),
|
||||
value.replaceAll(oldURL, newURL),
|
||||
"Pref correctly migrated"
|
||||
);
|
||||
Preferences.reset(pref);
|
||||
}
|
||||
});
|
|
@ -1,61 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"ExtensionStorageIDB",
|
||||
"resource://gre/modules/ExtensionStorageIDB.jsm"
|
||||
);
|
||||
|
||||
const ADDON_ID = "doh-rollout@mozilla.org";
|
||||
|
||||
add_task(setup);
|
||||
|
||||
add_task(async function testLocalStorageMigration() {
|
||||
Preferences.reset(prefs.BALROG_MIGRATION_PREF);
|
||||
|
||||
const legacyEntries = {
|
||||
doneFirstRun: true,
|
||||
"doh-rollout.doorhanger-decision": "UIOk",
|
||||
"doh-rollout.disable-heuristics": true,
|
||||
};
|
||||
|
||||
let policy = WebExtensionPolicy.getByID(ADDON_ID);
|
||||
|
||||
const storagePrincipal = ExtensionStorageIDB.getStoragePrincipal(
|
||||
policy.extension
|
||||
);
|
||||
|
||||
const idbConn = await ExtensionStorageIDB.open(storagePrincipal);
|
||||
await idbConn.set(legacyEntries);
|
||||
|
||||
let migrationDone = new Promise(resolve => {
|
||||
Preferences.observe(prefs.BALROG_MIGRATION_PREF, function obs() {
|
||||
Preferences.ignore(prefs.BALROG_MIGRATION_PREF, obs);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
await restartDoHController();
|
||||
await migrationDone;
|
||||
|
||||
for (let [key, value] of Object.entries(legacyEntries)) {
|
||||
if (!key.startsWith("doh-rollout")) {
|
||||
key = "doh-rollout." + key;
|
||||
}
|
||||
|
||||
is(
|
||||
Preferences.get(key),
|
||||
value,
|
||||
`${key} pref exists and has the right value ${value}`
|
||||
);
|
||||
|
||||
Preferences.reset(key);
|
||||
}
|
||||
|
||||
await idbConn.clear();
|
||||
await idbConn.close();
|
||||
});
|
|
@ -1,56 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(setup);
|
||||
|
||||
add_task(async function testTRRModeMigration() {
|
||||
// Test that previous TRR mode migration is correctly done - the dirtyEnable
|
||||
// test verifies that the migration is not performed when unnecessary.
|
||||
await DoHController._uninit();
|
||||
setPassingHeuristics();
|
||||
Preferences.set(prefs.NETWORK_TRR_MODE_PREF, 2);
|
||||
Preferences.set(prefs.PREVIOUS_TRR_MODE_PREF, 0);
|
||||
let modePromise = TestUtils.waitForPrefChange(prefs.NETWORK_TRR_MODE_PREF);
|
||||
let previousModePromise = TestUtils.waitForPrefChange(
|
||||
prefs.PREVIOUS_TRR_MODE_PREF
|
||||
);
|
||||
await DoHController.init();
|
||||
await Promise.all([modePromise, previousModePromise]);
|
||||
|
||||
is(
|
||||
Preferences.get(prefs.PREVIOUS_TRR_MODE_PREF),
|
||||
undefined,
|
||||
"Previous TRR mode pref cleared."
|
||||
);
|
||||
is(
|
||||
Preferences.isSet(prefs.NETWORK_TRR_MODE_PREF),
|
||||
false,
|
||||
"TRR mode cleared."
|
||||
);
|
||||
|
||||
await DoHController._uninit();
|
||||
Preferences.set(prefs.NETWORK_TRR_MODE_PREF, 5);
|
||||
Preferences.set(prefs.PREVIOUS_TRR_MODE_PREF, 0);
|
||||
previousModePromise = TestUtils.waitForPrefChange(
|
||||
prefs.PREVIOUS_TRR_MODE_PREF
|
||||
);
|
||||
await DoHController.init();
|
||||
try {
|
||||
await TestUtils.waitForCondition(
|
||||
() => !Preferences.isSet(prefs.NETWORK_TRR_MODE_PREF)
|
||||
);
|
||||
ok(false, "TRR mode should not have been cleared after migration");
|
||||
} catch (e) {
|
||||
ok(true, "TRR mode wasn't cleared after migration");
|
||||
}
|
||||
await previousModePromise;
|
||||
is(
|
||||
Preferences.get(prefs.PREVIOUS_TRR_MODE_PREF),
|
||||
undefined,
|
||||
"Previous TRR mode pref cleared."
|
||||
);
|
||||
is(Preferences.get(prefs.NETWORK_TRR_MODE_PREF), 5, "TRR mode remained 5.");
|
||||
});
|
|
@ -43,8 +43,6 @@ const prefs = {
|
|||
SKIP_HEURISTICS_PREF: "doh-rollout.skipHeuristicsCheck",
|
||||
CLEAR_ON_SHUTDOWN_PREF: "doh-rollout.clearModeOnShutdown",
|
||||
FIRST_RUN_PREF: "doh-rollout.doneFirstRun",
|
||||
BALROG_MIGRATION_PREF: "doh-rollout.balrog-migration-done",
|
||||
PREVIOUS_TRR_MODE_PREF: "doh-rollout.previous.trr.mode",
|
||||
PROVIDER_LIST_PREF: "doh-rollout.provider-list",
|
||||
TRR_SELECT_ENABLED_PREF: "doh-rollout.trr-selection.enabled",
|
||||
TRR_SELECT_URI_PREF: "doh-rollout.uri",
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "DoH Roll-Out",
|
||||
"description": "This used to be a Mozilla add-on that supported the roll-out of DoH, but now only exists as a stub to enable migrations.",
|
||||
"version": "2.0.0",
|
||||
|
||||
"hidden": true,
|
||||
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "doh-rollout@mozilla.org",
|
||||
"strict_min_version": "72.0a1"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DEFINES["MOZ_APP_VERSION"] = CONFIG["MOZ_APP_VERSION"]
|
||||
DEFINES["MOZ_APP_MAXVERSION"] = CONFIG["MOZ_APP_MAXVERSION"]
|
||||
|
||||
|
||||
FINAL_TARGET_FILES.features["doh-rollout@mozilla.org"] += ["manifest.json"]
|
||||
|
||||
with Files("**"):
|
||||
BUG_COMPONENT = ("Firefox", "Security")
|
|
@ -5,7 +5,6 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS += [
|
||||
"doh-rollout",
|
||||
"formautofill",
|
||||
"screenshots",
|
||||
"webcompat",
|
||||
|
|
Загрузка…
Ссылка в новой задаче