зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1450801 Part 2: Remove AddonManager support for telemetry experiments. r=kmag
MozReview-Commit-ID: FkQd7Ia5Tv4 --HG-- extra : rebase_source : 21ca3916b88492bc6d998673cdeaac4140cfb8f4 extra : histedit_source : c84a3ee00b4edf6c9b96fba8545f18ed12093222
This commit is contained in:
Родитель
a46219a92b
Коммит
9a813802d3
|
@ -24,6 +24,7 @@ generated-files =
|
|||
[test_disableExperiments.js]
|
||||
[test_fetch.js]
|
||||
[test_telemetry.js]
|
||||
skip-if = true # To be removed soon in bug 1420908
|
||||
[test_telemetry_disabled.js]
|
||||
[test_previous_provider.js]
|
||||
[test_upgrade.js]
|
||||
|
|
|
@ -158,14 +158,15 @@ const PROP_TARGETAPP = ["id", "minVersion", "maxVersion"];
|
|||
|
||||
// Map new string type identifiers to old style nsIUpdateItem types.
|
||||
// Retired values:
|
||||
// 8 = locale
|
||||
// 32 = multipackage xpi file
|
||||
// 8 = locale
|
||||
// 256 = apiextension
|
||||
// 128 = experiment
|
||||
const TYPES = {
|
||||
extension: 2,
|
||||
theme: 4,
|
||||
dictionary: 64,
|
||||
experiment: 128,
|
||||
};
|
||||
|
||||
const COMPATIBLE_BY_DEFAULT_TYPES = {
|
||||
|
@ -175,7 +176,6 @@ const COMPATIBLE_BY_DEFAULT_TYPES = {
|
|||
|
||||
const RESTARTLESS_TYPES = new Set([
|
||||
"dictionary",
|
||||
"experiment",
|
||||
"webextension",
|
||||
"webextension-theme",
|
||||
]);
|
||||
|
@ -807,10 +807,6 @@ async function loadManifestFromRDF(aUri, aData) {
|
|||
if (isTheme(addon.type)) {
|
||||
addon.userDisabled = !!LightweightThemeManager.currentTheme ||
|
||||
addon.internalName != DEFAULT_SKIN;
|
||||
} else if (addon.type == "experiment") {
|
||||
// Experiments are disabled by default. It is up to the Experiments Manager
|
||||
// to enable them (it drives installation).
|
||||
addon.userDisabled = true;
|
||||
} else {
|
||||
addon.userDisabled = false;
|
||||
}
|
||||
|
@ -818,13 +814,6 @@ async function loadManifestFromRDF(aUri, aData) {
|
|||
addon.softDisabled = addon.blocklistState == nsIBlocklistService.STATE_SOFTBLOCKED;
|
||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
|
||||
|
||||
// Experiments are managed and updated through an external "experiments
|
||||
// manager." So disable some built-in mechanisms.
|
||||
if (addon.type == "experiment") {
|
||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
|
||||
addon.updateURL = null;
|
||||
}
|
||||
|
||||
// icons will be filled by the calling function
|
||||
addon.icons = {};
|
||||
addon.userPermissions = null;
|
||||
|
|
|
@ -201,12 +201,10 @@ const TYPE_ALIASES = {
|
|||
|
||||
const CHROME_TYPES = new Set([
|
||||
"extension",
|
||||
"experiment",
|
||||
]);
|
||||
|
||||
const SIGNED_TYPES = new Set([
|
||||
"extension",
|
||||
"experiment",
|
||||
"webextension",
|
||||
"webextension-langpack",
|
||||
"webextension-theme",
|
||||
|
@ -220,7 +218,6 @@ const LEGACY_TYPES = new Set([
|
|||
const ALL_EXTERNAL_TYPES = new Set([
|
||||
"dictionary",
|
||||
"extension",
|
||||
"experiment",
|
||||
"locale",
|
||||
"theme",
|
||||
]);
|
||||
|
@ -811,16 +808,6 @@ function isUsableAddon(aAddon) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Experiments are installed through an external mechanism that
|
||||
// limits target audience to compatible clients. We trust it knows what
|
||||
// it's doing and skip compatibility checks.
|
||||
//
|
||||
// This decision does forfeit defense in depth. If the experiments system
|
||||
// is ever wrong about targeting an add-on to a specific application
|
||||
// or platform, the client will likely see errors.
|
||||
if (aAddon.type == "experiment")
|
||||
return true;
|
||||
|
||||
if (AddonManager.checkUpdateSecurity && !aAddon.providesUpdatesSecurely) {
|
||||
logger.warn(`Updates for add-on ${aAddon.id} must be provided over HTTPS.`);
|
||||
return false;
|
||||
|
@ -1291,9 +1278,7 @@ class XPIStateLocation extends Map {
|
|||
}
|
||||
|
||||
for (let [id, addon] of this.entries()) {
|
||||
if (addon.type != "experiment") {
|
||||
json.addons[id] = addon;
|
||||
}
|
||||
json.addons[id] = addon;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
@ -3473,12 +3458,9 @@ var XPIProvider = {
|
|||
if (this.isDBLoaded) {
|
||||
return new Promise(resolve => {
|
||||
this.getAddonsByTypes(aTypes, addons => {
|
||||
// The thing with experiments is an ugly hack but we want
|
||||
// Experiments.jsm to use this interface instead of getAddonsByTypes.
|
||||
// They'll go away at some point and we can forget this ever happened.
|
||||
resolve({addons: addons.filter(addon => addon.isActive ||
|
||||
(addon.type == "experiment" && !addon.appDisabled)),
|
||||
fullData: true
|
||||
resolve({
|
||||
addons: addons.filter(addon => addon.isActive),
|
||||
fullData: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -4658,12 +4640,10 @@ AddonInternal.prototype = {
|
|||
// Add-ons that are in locked install locations, or are pending uninstall
|
||||
// cannot be upgraded or uninstalled
|
||||
if (!this._installLocation.locked && !this.pendingUninstall) {
|
||||
// Experiments cannot be upgraded.
|
||||
// System add-on upgrades are triggered through a different mechanism (see updateSystemAddons())
|
||||
let isSystem = this._installLocation.isSystem;
|
||||
// Add-ons that are installed by a file link cannot be upgraded.
|
||||
if (this.type != "experiment" &&
|
||||
!this._installLocation.isLinkedAddon(this.id) && !isSystem) {
|
||||
if (!this._installLocation.isLinkedAddon(this.id) && !isSystem) {
|
||||
permissions |= AddonManager.PERM_CAN_UPGRADE;
|
||||
}
|
||||
|
||||
|
@ -4840,11 +4820,6 @@ AddonWrapper.prototype = {
|
|||
},
|
||||
set applyBackgroundUpdates(val) {
|
||||
let addon = addonFor(this);
|
||||
if (this.type == "experiment") {
|
||||
logger.warn("Setting applyBackgroundUpdates on an experiment is not supported.");
|
||||
return addon.applyBackgroundUpdates;
|
||||
}
|
||||
|
||||
if (val != AddonManager.AUTOUPDATE_DEFAULT &&
|
||||
val != AddonManager.AUTOUPDATE_DISABLE &&
|
||||
val != AddonManager.AUTOUPDATE_ENABLE) {
|
||||
|
@ -5059,14 +5034,6 @@ AddonWrapper.prototype = {
|
|||
},
|
||||
|
||||
findUpdates(aListener, aReason, aAppVersion, aPlatformVersion) {
|
||||
// Short-circuit updates for experiments because updates are handled
|
||||
// through the Experiments Manager.
|
||||
if (this.type == "experiment") {
|
||||
AddonManagerPrivate.callNoUpdateListeners(this, aListener, aReason,
|
||||
aAppVersion, aPlatformVersion);
|
||||
return;
|
||||
}
|
||||
|
||||
new UpdateChecker(addonFor(this), aListener, aReason, aAppVersion, aPlatformVersion);
|
||||
},
|
||||
|
||||
|
|
|
@ -206,16 +206,7 @@ Object.assign(DBAddonInternal.prototype, {
|
|||
},
|
||||
|
||||
toJSON() {
|
||||
let jsonData = copyProperties(this, PROP_JSON_FIELDS);
|
||||
|
||||
// Experiments are serialized as disabled so they aren't run on the next
|
||||
// startup.
|
||||
if (this.type == "experiment") {
|
||||
jsonData.userDisabled = true;
|
||||
jsonData.active = false;
|
||||
}
|
||||
|
||||
return jsonData;
|
||||
return copyProperties(this, PROP_JSON_FIELDS);
|
||||
},
|
||||
|
||||
get inDatabase() {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
ChromeUtils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this);
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>experiment1@tests.mozilla.org</em:id>
|
||||
<em:version>1.0</em:version>
|
||||
<em:type>128</em:type>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Test Experiment 1</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -1,142 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const ID = "experiment1@tests.mozilla.org";
|
||||
|
||||
var gIsNightly = false;
|
||||
|
||||
function getXS() {
|
||||
let XPI = ChromeUtils.import("resource://gre/modules/addons/XPIProvider.jsm", {});
|
||||
return XPI.XPIStates;
|
||||
}
|
||||
|
||||
function getBootstrappedAddons() {
|
||||
let obj = {};
|
||||
for (let addon of getXS().bootstrappedAddons()) {
|
||||
obj[addon.id] = addon;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
BootstrapMonitor.init();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
startupManager();
|
||||
|
||||
gIsNightly = isNightlyChannel();
|
||||
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(async function test_experiment() {
|
||||
BootstrapMonitor.checkAddonNotInstalled(ID);
|
||||
BootstrapMonitor.checkAddonNotStarted(ID);
|
||||
|
||||
await promiseInstallAllFiles([do_get_addon("test_experiment1")]);
|
||||
|
||||
BootstrapMonitor.checkAddonInstalled(ID, "1.0");
|
||||
BootstrapMonitor.checkAddonNotStarted(ID);
|
||||
|
||||
let addon = await promiseAddonByID(ID);
|
||||
Assert.ok(addon, "Addon is found.");
|
||||
|
||||
Assert.ok(addon.userDisabled, "Experiments are userDisabled by default.");
|
||||
Assert.ok(!addon.appDisabled, "Experiments are not appDisabled by compatibility.");
|
||||
Assert.equal(addon.isActive, false, "Add-on is not active.");
|
||||
Assert.equal(addon.updateURL, null, "No updateURL for experiments.");
|
||||
Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
|
||||
"Background updates are disabled.");
|
||||
Assert.equal(addon.permissions, AddonManager.PERM_CAN_UNINSTALL + AddonManager.PERM_CAN_ENABLE,
|
||||
"Permissions are minimal.");
|
||||
Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
|
||||
"Should not be pending enable");
|
||||
Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
|
||||
"Should not be pending disable");
|
||||
|
||||
// Setting applyBackgroundUpdates should not work.
|
||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
|
||||
Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
|
||||
"Setting applyBackgroundUpdates shouldn't do anything.");
|
||||
|
||||
let noCompatibleCalled = false;
|
||||
let noUpdateCalled = false;
|
||||
let finishedCalled = false;
|
||||
|
||||
let listener = {
|
||||
onNoCompatibilityUpdateAvailable: () => { noCompatibleCalled = true; },
|
||||
onNoUpdateAvailable: () => { noUpdateCalled = true; },
|
||||
onUpdateFinished: () => { finishedCalled = true; },
|
||||
};
|
||||
|
||||
addon.findUpdates(listener, "testing", null, null);
|
||||
Assert.ok(noCompatibleCalled, "Listener called.");
|
||||
Assert.ok(noUpdateCalled, "Listener called.");
|
||||
Assert.ok(finishedCalled, "Listener called.");
|
||||
});
|
||||
|
||||
// Changes to userDisabled should not be persisted to the database.
|
||||
add_task(async function test_userDisabledNotPersisted() {
|
||||
let addon = await promiseAddonByID(ID);
|
||||
Assert.ok(addon, "Add-on is found.");
|
||||
Assert.ok(addon.userDisabled, "Add-on is user disabled.");
|
||||
|
||||
let promise = promiseAddonEvent("onEnabled");
|
||||
addon.userDisabled = false;
|
||||
let [addon2] = await promise;
|
||||
|
||||
BootstrapMonitor.checkAddonInstalled(ID, "1.0");
|
||||
BootstrapMonitor.checkAddonStarted(ID, "1.0");
|
||||
|
||||
Assert.equal(addon2.id, addon.id, "Changed add-on matches expected.");
|
||||
Assert.equal(addon2.userDisabled, false, "Add-on is no longer user disabled.");
|
||||
Assert.ok(addon2.isActive, "Add-on is active.");
|
||||
|
||||
Assert.ok(ID in getBootstrappedAddons(),
|
||||
"Experiment add-on listed in XPIProvider bootstrapped list.");
|
||||
|
||||
addon = await promiseAddonByID(ID);
|
||||
Assert.ok(addon, "Add-on retrieved.");
|
||||
Assert.equal(addon.userDisabled, false, "Add-on is still enabled after API retrieve.");
|
||||
Assert.ok(addon.isActive, "Add-on is still active.");
|
||||
Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
|
||||
"Should not be pending enable");
|
||||
Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
|
||||
"Should not be pending disable");
|
||||
|
||||
// Now when we restart the manager the add-on should revert state.
|
||||
await promiseRestartManager();
|
||||
|
||||
Assert.ok(!(ID in getBootstrappedAddons()),
|
||||
"Experiment add-on not persisted to bootstrappedAddons.");
|
||||
|
||||
BootstrapMonitor.checkAddonInstalled(ID, "1.0");
|
||||
BootstrapMonitor.checkAddonNotStarted(ID);
|
||||
|
||||
addon = await promiseAddonByID(ID);
|
||||
Assert.ok(addon, "Add-on retrieved.");
|
||||
Assert.ok(addon.userDisabled, "Add-on is disabled after restart.");
|
||||
Assert.equal(addon.isActive, false, "Add-on is not active after restart.");
|
||||
addon.uninstall();
|
||||
|
||||
BootstrapMonitor.checkAddonNotInstalled(ID);
|
||||
BootstrapMonitor.checkAddonNotStarted(ID);
|
||||
});
|
||||
|
||||
add_task(async function test_checkCompatibility() {
|
||||
if (gIsNightly)
|
||||
Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
|
||||
else
|
||||
Services.prefs.setBoolPref("extensions.checkCompatibility.1", false);
|
||||
|
||||
await promiseRestartManager();
|
||||
|
||||
await promiseInstallAllFiles([do_get_addon("test_experiment1")]);
|
||||
let addon = await promiseAddonByID(ID);
|
||||
|
||||
BootstrapMonitor.checkAddonInstalled(ID, "1.0");
|
||||
BootstrapMonitor.checkAddonNotStarted(ID);
|
||||
|
||||
Assert.ok(addon, "Add-on is found.");
|
||||
Assert.ok(addon.userDisabled, "Add-on is user disabled.");
|
||||
Assert.ok(!addon.appDisabled, "Add-on is not app disabled.");
|
||||
});
|
|
@ -96,9 +96,6 @@ tags = webextensions
|
|||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_error.js]
|
||||
[test_experiment.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_ext_management.js]
|
||||
skip-if = appname == "thunderbird"
|
||||
tags = webextensions
|
||||
|
|
Загрузка…
Ссылка в новой задаче