Issue #21 - Part 1: Remove experiments base code from the Add-ons Manager

The experiments manager was already removed in bf6bb142fc5bcb49b053788e06160af304f639e5 and this was imported dead code from Tycho AM.
This commit is contained in:
FranklinDM 2023-06-19 21:32:45 +08:00 committed by roytam1
commit 369e68a663
4 changed files with 11 additions and 217 deletions

View file

@ -202,10 +202,6 @@ setting[type="menulist"] {
display: none;
}
#addons-page .view-pane:not([type="experiment"]) .experiment-info-container {
display: none;
}
.addon .relnotes {
-moz-user-select: text;
}
@ -236,36 +232,6 @@ richlistitem:not([selected]) * {
display: none;
}
#experiments-learn-more[disabled="true"] {
display: none;
}
#experiments-change-telemetry[disabled="true"] {
display: none;
}
.view-pane[type="experiment"] .error,
.view-pane[type="experiment"] .warning,
.view-pane[type="experiment"] .addon:not([pending="uninstall"]) .pending,
.view-pane[type="experiment"] .disabled-postfix,
.view-pane[type="experiment"] .update-postfix,
.view-pane[type="experiment"] .version,
#detail-view[type="experiment"] .alert-container,
#detail-view[type="experiment"] #detail-version,
#detail-view[type="experiment"] #detail-creator {
display: none;
}
.view-pane:not([type="experiment"]) .experiment-container,
.view-pane:not([type="experiment"]) #detail-experiment-container {
display: none;
}
.addon[type="experiment"][status="installing"] .experiment-time,
.addon[type="experiment"][status="installing"] .experiment-state {
display: none;
}
/* Indicator style for extension target application */
.addon[native] .nativeIndicator {
margin-left: 5pt;

View file

@ -868,15 +868,6 @@
<xul:label anonid="date-updated" class="date-updated"
unknown="&addon.unknownDate;"/>
</xul:hbox>
<xul:hbox class="experiment-container">
<svg width="6" height="6" viewBox="0 0 6 6" version="1.1"
xmlns="http://www.w3.org/2000/svg"
class="experiment-bullet-container">
<circle cx="3" cy="3" r="3" class="experiment-bullet"/>
</svg>
<xul:label anonid="experiment-state" class="experiment-state"/>
<xul:label anonid="experiment-time" class="experiment-time"/>
</xul:hbox>
<xul:hbox class="advancedinfo-container" flex="1">
<xul:vbox class="description-outer-container" flex="1">
@ -1042,12 +1033,6 @@
<field name="_version">
document.getAnonymousElementByAttribute(this, "anonid", "version");
</field>
<field name="_experimentState">
document.getAnonymousElementByAttribute(this, "anonid", "experiment-state");
</field>
<field name="_experimentTime">
document.getAnonymousElementByAttribute(this, "anonid", "experiment-time");
</field>
<field name="_icon">
document.getAnonymousElementByAttribute(this, "anonid", "icon");
</field>
@ -1419,37 +1404,6 @@
var showProgress = this.mAddon.purchaseURL || (this.mAddon.install &&
this.mAddon.install.state != AddonManager.STATE_INSTALLED);
this._showStatus(showProgress ? "progress" : "none");
if (this.mAddon.type == "experiment") {
this.removeAttribute("notification");
let prefix = "experiment.";
let active = this.mAddon.isActive;
if (!showProgress) {
let stateKey = prefix + "state." + (active ? "active" : "complete");
this._experimentState.value = gStrings.ext.GetStringFromName(stateKey);
let now = Date.now();
let end = this.endDate;
let days = Math.abs(end - now) / (24 * 60 * 60 * 1000);
let timeKey = prefix + "time.";
let timeMessage;
if (days < 1) {
timeKey += (active ? "endsToday" : "endedToday");
timeMessage = gStrings.ext.GetStringFromName(timeKey);
} else {
timeKey += (active ? "daysRemaining" : "daysPassed");
days = Math.round(days);
let timeString = gStrings.ext.GetStringFromName(timeKey);
timeMessage = PluralForm.get(days, timeString)
.replace("#1", days);
}
this._experimentTime.value = timeMessage;
}
}
]]></body>
</method>

View file

@ -91,8 +91,6 @@
<command id="cmd_enableUpdateSecurity"/>
<command id="cmd_toggleAutoUpdateDefault"/>
<command id="cmd_resetAddonAutoUpdate"/>
<command id="cmd_experimentsLearnMore"/>
<command id="cmd_experimentsOpenTelemetryPreferences"/>
</commandset>
<!-- view commands - these act on the selected addon -->
@ -354,22 +352,6 @@
<spacer flex="5000"/> <!-- Necessary to allow the message to wrap -->
</hbox>
</hbox>
<hbox class="view-header global-info-container experiment-info-container">
<hbox class="global-info" flex="1" align="center">
<label value="&experiment.info.label;"/>
<button id="experiments-learn-more"
label="&experiment.info.learnmore;"
tooltiptext="&experiment.info.learnmore;"
accesskey="&experiment.info.learnmore.accesskey;"
command="cmd_experimentsLearnMore"/>
<button id="experiments-change-telemetry"
label="&experiment.info.changetelemetry;"
tooltiptext="&experiment.info.changetelemetry;"
accesskey="&experiment.info.changetelemetry.accesskey;"
command="cmd_experimentsOpenTelemetryPreferences"/>
<spacer flex="5000"/> <!-- Necessary to allow the message to wrap. -->
</hbox>
</hbox>
<vbox id="addon-list-empty" class="alert-container"
flex="1" hidden="true">
<spacer class="alert-spacer-before"/>
@ -530,15 +512,6 @@
<label id="detail-creator" class="creator"/>
<label id="detail-translators" class="translators"/>
</vbox>
<hbox id="detail-experiment-container">
<svg width="8" height="8" viewBox="0 0 8 8" version="1.1"
xmlns="http://www.w3.org/2000/svg"
id="detail-experiment-bullet-container">
<circle cx="4" cy="4" r="4" id="detail-experiment-bullet"/>
</svg>
<label id="detail-experiment-state"/>
<label id="detail-experiment-time"/>
</hbox>
<hbox id="detail-desc-container" align="start">
<vbox pack="center"> <!-- Necessary to work around bug 394738 -->
<image id="detail-screenshot" hidden="true"/>

View file

@ -197,12 +197,10 @@ const TYPES = {
locale: 8,
multipackage: 32,
dictionary: 64,
experiment: 128,
};
const RESTARTLESS_TYPES = new Set([
"dictionary",
"experiment",
"locale",
]);
@ -944,30 +942,13 @@ function loadManifestFromRDF(aUri, aStream) {
if (addon.type == "theme") {
addon.userDisabled = !!LightweightThemeManager.currentTheme ||
addon.internalName != XPIProvider.selectedSkin;
}
// Experiments are disabled by default. It is up to the Experiments Manager
// to enable them (it drives installation).
else if (addon.type == "experiment") {
addon.userDisabled = true;
}
else {
} else {
addon.userDisabled = false;
addon.softDisabled = addon.blocklistState == Blocklist.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;
addon.updateKey = null;
addon.targetApplications = [];
addon.targetPlatforms = [];
}
// Load the storage service before NSS (nsIRandomGenerator),
// to avoid a SQLite initialization error (bug 717904).
let storage = Services.storage;
@ -1828,8 +1809,6 @@ this.XPIProvider = {
// Keep track of the newest file in each add-on, in case we want to
// report it.
_mostRecentlyModifiedFile: {},
// Experiments are disabled by default. Track ones that are locally enabled.
_enabledExperiments: null,
// A Map from an add-on install to its ID
_addonFileMap: new Map(),
#ifdef MOZ_DEVTOOLS
@ -2003,8 +1982,6 @@ this.XPIProvider = {
this.installLocationsByName = {};
// Hook for tests to detect when saving database at shutdown time fails
this._shutdownError = null;
// Clear the set of enabled experiments (experiments disabled by default).
this._enabledExperiments = new Set();
let hasRegistry = ("nsIWindowsRegKey" in Ci);
@ -2317,19 +2294,8 @@ this.XPIProvider = {
* Persists changes to XPIProvider.bootstrappedAddons to its store (a pref).
*/
persistBootstrappedAddons: function XPI_persistBootstrappedAddons() {
// Experiments are disabled upon app load, so don't persist references.
let filtered = {};
for (let id in this.bootstrappedAddons) {
let entry = this.bootstrappedAddons[id];
if (entry.type == "experiment") {
continue;
}
filtered[id] = entry;
}
Services.prefs.setCharPref(PREF_BOOTSTRAP_ADDONS,
JSON.stringify(filtered));
JSON.stringify(this.bootstrappedAddons));
},
/**
@ -4487,15 +4453,11 @@ this.XPIProvider = {
let appDisabledChanged = aAddon.appDisabled != appDisabled;
// Update the properties in the database.
// We never persist this for experiments because the disabled flags
// are controlled by the Experiments Manager.
if (aAddon.type != "experiment") {
XPIDatabase.setAddonProperties(aAddon, {
userDisabled: aUserDisabled,
appDisabled: appDisabled,
softDisabled: aSoftDisabled
});
}
XPIDatabase.setAddonProperties(aAddon, {
userDisabled: aUserDisabled,
appDisabled: appDisabled,
softDisabled: aSoftDisabled
});
if (appDisabledChanged) {
AddonManagerPrivate.callAddonListeners("onPropertyChanged",
@ -6389,17 +6351,6 @@ AddonInternal.prototype = {
},
isCompatibleWith: function AddonInternal_isCompatibleWith(aAppVersion, aPlatformVersion) {
// 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 (this.type == "experiment") {
return true;
}
let app = this.matchingTargetApplication;
if (!app)
return false;
@ -6610,13 +6561,6 @@ AddonInternal.prototype = {
if (!(this.inDatabase))
return permissions;
// Experiments can only be uninstalled. An uninstall reflects the user
// intent of "disable this experiment." This is partially managed by the
// experiments manager.
if (this.type == "experiment") {
return AddonManager.PERM_CAN_UNINSTALL;
}
if (!this.appDisabled) {
if (this.userDisabled || this.softDisabled) {
permissions |= AddonManager.PERM_CAN_ENABLE;
@ -6879,11 +6823,6 @@ function AddonWrapper(aAddon) {
return aAddon.applyBackgroundUpdates;
});
this.__defineSetter__("applyBackgroundUpdates", function AddonWrapper_applyBackgroundUpdatesSetter(val) {
if (this.type == "experiment") {
logger.warn("Setting applyBackgroundUpdates on an experiment is not supported.");
return;
}
if (val != AddonManager.AUTOUPDATE_DEFAULT &&
val != AddonManager.AUTOUPDATE_DISABLE &&
val != AddonManager.AUTOUPDATE_ENABLE) {
@ -6948,15 +6887,10 @@ function AddonWrapper(aAddon) {
return AddonManager.PENDING_UNINSTALL;
}
// Extensions have an intentional inconsistency between what the DB says is
// enabled and what we say to the ouside world. so we need to cover up that
// lie here as well.
if (aAddon.type != "experiment") {
if (aAddon.active && aAddon.disabled)
pending |= AddonManager.PENDING_DISABLE;
else if (!aAddon.active && !aAddon.disabled)
pending |= AddonManager.PENDING_ENABLE;
}
if (aAddon.active && aAddon.disabled)
pending |= AddonManager.PENDING_DISABLE;
else if (!aAddon.active && !aAddon.disabled)
pending |= AddonManager.PENDING_ENABLE;
if (aAddon.pendingUpgrade)
pending |= AddonManager.PENDING_UPGRADE;
@ -6993,10 +6927,6 @@ function AddonWrapper(aAddon) {
});
this.__defineGetter__("userDisabled", function AddonWrapper_userDisabledGetter() {
if (XPIProvider._enabledExperiments.has(aAddon.id)) {
return false;
}
return aAddon.softDisabled || aAddon.userDisabled;
});
this.__defineSetter__("userDisabled", function AddonWrapper_userDisabledSetter(val) {
@ -7004,14 +6934,6 @@ function AddonWrapper(aAddon) {
return val;
}
if (aAddon.type == "experiment") {
if (val) {
XPIProvider._enabledExperiments.delete(aAddon.id);
} else {
XPIProvider._enabledExperiments.add(aAddon.id);
}
}
if (aAddon.inDatabase) {
if (aAddon.type == "theme" && val) {
if (aAddon.internalName == XPIProvider.defaultSkin)
@ -7069,14 +6991,6 @@ function AddonWrapper(aAddon) {
};
this.findUpdates = function AddonWrapper_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(aAddon, aListener, aReason, aAppVersion, aPlatformVersion);
};
@ -7813,17 +7727,4 @@ var addonTypes = [
AddonManager.TYPE_UI_HIDE_EMPTY | AddonManager.TYPE_SUPPORTS_UNDO_RESTARTLESS_UNINSTALL),
];
// We only register experiments support if the application supports them.
// Ideally, we would install an observer to watch the pref. Installing
// an observer for this pref is not necessary here and may be buggy with
// regards to registering this XPIProvider twice.
if (Preferences.get("experiments.supported", false)) {
addonTypes.push(
new AddonManagerPrivate.AddonType("experiment",
URI_EXTENSION_STRINGS,
STRING_TYPE_NAME,
AddonManager.VIEW_TYPE_LIST, 11000,
AddonManager.TYPE_UI_HIDE_EMPTY | AddonManager.TYPE_SUPPORTS_UNDO_RESTARTLESS_UNINSTALL));
}
AddonManagerPrivate.registerProvider(XPIProvider, addonTypes);