Backed out changeset 527ed2d24327 (bug 1575948) for browser chrome failures on browser_startup_mainthreadio.js. CLOSED TREE

This commit is contained in:
Cosmin Sabou 2020-05-11 20:05:18 +03:00
Родитель c7662689a3
Коммит 0749be7712
7 изменённых файлов: 23 добавлений и 359 удалений

Просмотреть файл

@ -1799,11 +1799,9 @@ var AddonManagerInternal = {
* @param aTelemetryInfo
* An optional object which provides details about the installation source
* included in the addon manager telemetry events.
* @param aUseSystemLocation
* If true the addon is installed into the system profile location.
* @throws if the aFile or aCallback arguments are not specified
*/
getInstallForFile(aFile, aMimetype, aTelemetryInfo, aUseSystemLocation) {
getInstallForFile(aFile, aMimetype, aTelemetryInfo) {
if (!gStarted) {
throw Components.Exception(
"AddonManager is not initialized",
@ -1831,8 +1829,7 @@ var AddonManagerInternal = {
provider,
"getInstallForFile",
aFile,
aTelemetryInfo,
aUseSystemLocation
aTelemetryInfo
);
if (install) {
@ -1844,25 +1841,6 @@ var AddonManagerInternal = {
})();
},
/**
* Uninstall an addon from the system profile location.
*
* @param {string} aID
* The ID of the addon to remove.
* @returns A promise that resolves when the addon is uninstalled.
*/
uninstallSystemProfileAddon(aID) {
if (!gStarted) {
throw Components.Exception(
"AddonManager is not initialized",
Cr.NS_ERROR_NOT_INITIALIZED
);
}
return AddonManagerInternal._getProviderByName(
"XPIProvider"
).uninstallSystemProfileAddon(aID);
},
/**
* Asynchronously gets all current AddonInstalls optionally limiting to a list
* of types.
@ -3979,24 +3957,14 @@ var AddonManager = {
return AddonManagerInternal.getInstallForURL(aUrl, aOptions);
},
getInstallForFile(
aFile,
aMimetype,
aTelemetryInfo,
aUseSystemLocation = false
) {
getInstallForFile(aFile, aMimetype, aTelemetryInfo) {
return AddonManagerInternal.getInstallForFile(
aFile,
aMimetype,
aTelemetryInfo,
aUseSystemLocation
aTelemetryInfo
);
},
uninstallSystemProfileAddon(aID) {
return AddonManagerInternal.uninstallSystemProfileAddon(aID);
},
/**
* Gets an array of add-on IDs that changed during the most recent startup.
*

Просмотреть файл

@ -88,7 +88,6 @@ const TOOLKIT_ID = "toolkit@mozilla.org";
const KEY_APP_SYSTEM_ADDONS = "app-system-addons";
const KEY_APP_SYSTEM_DEFAULTS = "app-system-defaults";
const KEY_APP_SYSTEM_PROFILE = "app-system-profile";
const KEY_APP_BUILTINS = "app-builtin";
const KEY_APP_SYSTEM_LOCAL = "app-system-local";
const KEY_APP_SYSTEM_SHARE = "app-system-share";
@ -408,13 +407,6 @@ class AddonInternal {
get isCorrectlySigned() {
switch (this.location.name) {
case KEY_APP_SYSTEM_PROFILE:
// Add-ons installed via Normandy must be signed by the system
// key or the "Mozilla Extensions" key.
return [
AddonManager.SIGNEDSTATE_SYSTEM,
AddonManager.SIGNEDSTATE_PRIVILEGED,
].includes(this.signedState);
case KEY_APP_SYSTEM_ADDONS:
// System add-ons must be signed by the system key.
return this.signedState == AddonManager.SIGNEDSTATE_SYSTEM;

Просмотреть файл

@ -117,18 +117,11 @@ const PREF_SELECTED_LWT = "lightweightThemes.selectedThemeID";
const TOOLKIT_ID = "toolkit@mozilla.org";
/* globals BOOTSTRAP_REASONS, DIR_STAGE, DIR_TRASH, KEY_APP_PROFILE, KEY_APP_SYSTEM_ADDONS, KEY_APP_SYSTEM_DEFAULTS,
KEY_APP_SYSTEM_PROFILE, KEY_PROFILEDIR, PREF_BRANCH_INSTALLED_ADDON, PREF_SYSTEM_ADDON_SET, TEMPORARY_ADDON_SUFFIX,
XPI_PERMISSION, XPIStates, getURIForResourceInFile, iterDirectory */
/* globals BOOTSTRAP_REASONS, KEY_APP_SYSTEM_ADDONS, KEY_APP_SYSTEM_DEFAULTS, PREF_BRANCH_INSTALLED_ADDON, PREF_SYSTEM_ADDON_SET, TEMPORARY_ADDON_SUFFIX, XPI_PERMISSION, XPIStates, getURIForResourceInFile, iterDirectory */
const XPI_INTERNAL_SYMBOLS = [
"BOOTSTRAP_REASONS",
"DIR_STAGE",
"DIR_TRASH",
"KEY_APP_PROFILE",
"KEY_APP_SYSTEM_ADDONS",
"KEY_APP_SYSTEM_DEFAULTS",
"KEY_APP_SYSTEM_PROFILE",
"KEY_PROFILEDIR",
"PREF_BRANCH_INSTALLED_ADDON",
"PREF_SYSTEM_ADDON_SET",
"TEMPORARY_ADDON_SUFFIX",
@ -188,8 +181,14 @@ const PREF_XPI_SIGNATURES_DEV_ROOT = "xpinstall.signatures.dev-root";
const PREF_INSTALL_REQUIREBUILTINCERTS =
"extensions.install.requireBuiltInCerts";
const KEY_PROFILEDIR = "ProfD";
const KEY_TEMPDIR = "TmpD";
const KEY_APP_PROFILE = "app-profile";
const DIR_STAGE = "staged";
const DIR_TRASH = "trash";
// This is a random number array that can be used as "salt" when generating
// an automatic ID based on the directory path of an add-on. It will prevent
// someone from creating an ID for a permanent add-on that could be replaced
@ -841,27 +840,17 @@ function getSignedStatus(aRv, aCert, aAddonID) {
}
function shouldVerifySignedState(aAddon) {
// TODO when KEY_APP_SYSTEM_DEFAULTS and KEY_APP_SYSTEM_ADDONS locations
// are removed, we need to reorganize the logic here. At that point we
// should:
// if builtin or MOZ_UNSIGNED_SCOPES return false
// if system return true
// return SIGNED_TYPES.has(type)
// Updated system add-ons should always have their signature checked
if (aAddon.location.name == KEY_APP_SYSTEM_ADDONS) {
return true;
}
// We don't care about signatures for default system add-ons
if (aAddon.location.name == KEY_APP_SYSTEM_DEFAULTS) {
return false;
}
// Updated system add-ons should always have their signature checked
if (aAddon.location.isSystem) {
return true;
}
if (
aAddon.location.isBuiltin ||
aAddon.location.scope & AppConstants.MOZ_UNSIGNED_SCOPES
) {
if (aAddon.location.scope & AppConstants.MOZ_UNSIGNED_SCOPES) {
return false;
}
@ -4187,24 +4176,12 @@ var XPIInstall = {
* @param {Object} [aOptions.telemetryInfo]
* An optional object which provides details about the installation source
* included in the addon manager telemetry events.
* @param {boolean} [aOptions.sendCookies = false]
* @param {boolean} [options.sendCookies = false]
* Whether cookies should be sent when downloading the add-on.
* @param {string} [aOptions.useSystemLocation = false]
* If true installs to the system profile location.
* @returns {AddonInstall}
*/
async getInstallForURL(aUrl, aOptions) {
let locationName = aOptions.useSystemLocation
? KEY_APP_SYSTEM_PROFILE
: KEY_APP_PROFILE;
let location = XPIStates.getLocation(locationName);
if (!location) {
throw Components.Exception(
"Invalid location name",
Cr.NS_ERROR_INVALID_ARG
);
}
let location = XPIStates.getLocation(KEY_APP_PROFILE);
let url = Services.io.newURI(aUrl);
if (url instanceof Ci.nsIFileURL) {
@ -4225,23 +4202,10 @@ var XPIInstall = {
* @param {Object?} [aInstallTelemetryInfo]
* An optional object which provides details about the installation source
* included in the addon manager telemetry events.
* @param {boolean} [aUseSystemLocation = false]
* If true install to the system profile location.
* @returns {AddonInstall?}
*/
async getInstallForFile(
aFile,
aInstallTelemetryInfo,
aUseSystemLocation = false
) {
let location = XPIStates.getLocation(
aUseSystemLocation ? KEY_APP_SYSTEM_PROFILE : KEY_APP_PROFILE
);
let install = await createLocalInstall(
aFile,
location,
aInstallTelemetryInfo
);
async getInstallForFile(aFile, aInstallTelemetryInfo) {
let install = await createLocalInstall(aFile, null, aInstallTelemetryInfo);
return install ? install.wrapper : null;
},

Просмотреть файл

@ -92,7 +92,6 @@ const URI_EXTENSION_STRINGS =
const DIR_EXTENSIONS = "extensions";
const DIR_SYSTEM_ADDONS = "features";
const DIR_APP_SYSTEM_PROFILE = "system-extensions";
const DIR_STAGE = "staged";
const DIR_TRASH = "trash";
@ -104,7 +103,6 @@ const KEY_APP_DISTRIBUTION = "XREAppDist";
const KEY_APP_FEATURES = "XREAppFeat";
const KEY_APP_PROFILE = "app-profile";
const KEY_APP_SYSTEM_PROFILE = "app-system-profile";
const KEY_APP_SYSTEM_ADDONS = "app-system-addons";
const KEY_APP_SYSTEM_DEFAULTS = "app-system-defaults";
const KEY_APP_BUILTINS = "app-builtin";
@ -990,13 +988,10 @@ class DirectoryLocation extends XPIStateLocation {
* The scope of add-ons installed in this location.
* @param {boolean} [locked = true]
* If false, the location accepts new add-on installs.
* @param {boolean} [system = false]
* If true, the location is a system addon location.
*/
constructor(name, dir, scope, locked = true, system = false) {
constructor(name, dir, scope, locked = true) {
super(name, dir, scope);
this.locked = locked;
this._isSystem = system;
}
makeInstaller() {
@ -1119,10 +1114,6 @@ class DirectoryLocation extends XPIStateLocation {
}
return addons;
}
get isSystem() {
return this._isSystem;
}
}
/**
@ -2212,13 +2203,13 @@ var XPIProvider = {
},
setupInstallLocations(aAppChanged) {
function DirectoryLoc(aName, aScope, aKey, aPaths, aLocked, aIsSystem) {
function DirectoryLoc(aName, aScope, aKey, aPaths, aLocked) {
try {
var dir = FileUtils.getDir(aKey, aPaths);
} catch (e) {
return null;
}
return new DirectoryLocation(aName, dir, aScope, aLocked, aIsSystem);
return new DirectoryLocation(aName, dir, aScope, aLocked);
}
function SystemDefaultsLoc(name, scope, key, paths) {
@ -2259,16 +2250,6 @@ var XPIProvider = {
false,
],
[
DirectoryLoc,
KEY_APP_SYSTEM_PROFILE,
AddonManager.SCOPE_PROFILE,
KEY_PROFILEDIR,
[DIR_APP_SYSTEM_PROFILE],
false,
true,
],
[
SystemLoc,
KEY_APP_SYSTEM_ADDONS,
@ -3156,11 +3137,6 @@ var XPIProvider = {
}
}
},
uninstallSystemProfileAddon(aID) {
let location = XPIStates.getLocation(KEY_APP_SYSTEM_PROFILE);
return XPIInstall.uninstallAddonFromLocation(aID, location);
},
};
for (let meth of [
@ -3195,13 +3171,8 @@ var XPIInternal = {
BootstrapScope,
BuiltInLocation,
DB_SCHEMA,
DIR_STAGE,
DIR_TRASH,
KEY_APP_PROFILE,
KEY_APP_SYSTEM_PROFILE,
KEY_APP_SYSTEM_ADDONS,
KEY_APP_SYSTEM_DEFAULTS,
KEY_PROFILEDIR,
PREF_BRANCH_INSTALLED_ADDON,
PREF_SYSTEM_ADDON_SET,
SystemAddonLocation,

Просмотреть файл

@ -1,207 +0,0 @@
"use strict";
/* globals browser */
let scopes = AddonManager.SCOPE_PROFILE | AddonManager.SCOPE_APPLICATION;
Services.prefs.setIntPref("extensions.enabledScopes", scopes);
Services.prefs.setBoolPref(
"extensions.webextensions.background-delayed-startup",
false
);
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"1"
);
AddonTestUtils.usePrivilegedSignatures = id => id.startsWith("system");
async function promiseInstallSystemProfileExtension(id, hidden) {
let xpi = await AddonTestUtils.createTempWebExtensionFile({
manifest: {
applications: { gecko: { id } },
hidden,
},
background() {
browser.test.sendMessage("started");
},
});
let wrapper = ExtensionTestUtils.expectExtension(id);
const install = await AddonManager.getInstallForURL(`file://${xpi.path}`, {
useSystemLocation: true, // KEY_APP_SYSTEM_PROFILE
});
install.install();
await wrapper.awaitStartup();
await wrapper.awaitMessage("started");
return wrapper;
}
async function promiseUninstall(id) {
await AddonManager.uninstallSystemProfileAddon(id);
let addon = await promiseAddonByID(id);
equal(addon, null, "Addon is gone after uninstall");
}
// Tests installing an extension into the app-system-profile location.
add_task(async function test_system_profile_location() {
let id = "system@tests.mozilla.org";
await AddonTestUtils.promiseStartupManager();
let wrapper = await promiseInstallSystemProfileExtension(id);
let addon = await promiseAddonByID(id);
notEqual(addon, null, "Addon is installed");
ok(addon.isActive, "Addon is active");
ok(addon.isPrivileged, "Addon is privileged");
ok(!addon.hidden, "Addon is not hidden");
equal(
addon.signedState,
AddonManager.SIGNEDSTATE_PRIVILEGED,
"Addon is system signed"
);
// After a restart, the extension should start up normally.
await promiseRestartManager();
await wrapper.awaitStartup();
await wrapper.awaitMessage("started");
ok(true, "Extension in app-system-profile location ran after restart");
addon = await promiseAddonByID(id);
notEqual(addon, null, "Addon is installed");
ok(addon.isActive, "Addon is active");
// After a restart that causes a database rebuild, it should still work
await promiseRestartManager("2");
await wrapper.awaitStartup();
await wrapper.awaitMessage("started");
ok(true, "Extension in app-system-profile location ran after restart");
addon = await promiseAddonByID(id);
notEqual(addon, null, "Addon is installed");
ok(addon.isActive, "Addon is active");
// After a restart that changes the schema version, it should still work
await promiseShutdownManager();
Services.prefs.setIntPref("extensions.databaseSchema", 0);
await promiseStartupManager();
await wrapper.awaitStartup();
await wrapper.awaitMessage("started");
ok(true, "Extension in app-system-profile location ran after restart");
addon = await promiseAddonByID(id);
notEqual(addon, null, "Addon is installed");
ok(addon.isActive, "Addon is active");
await promiseUninstall(id);
await AddonTestUtils.promiseShutdownManager();
});
// Tests installing a hidden extension in the app-system-profile location.
add_task(async function test_system_profile_location_hidden() {
let id = "system-hidden@tests.mozilla.org";
await AddonTestUtils.promiseStartupManager();
await promiseInstallSystemProfileExtension(id, true);
let addon = await promiseAddonByID(id);
notEqual(addon, null, "Addon is installed");
ok(addon.isActive, "Addon is active");
ok(addon.isPrivileged, "Addon is privileged");
ok(addon.hidden, "Addon is hidden");
await promiseUninstall(id);
await AddonTestUtils.promiseShutdownManager();
});
add_task(async function test_system_profile_location_installFile() {
await AddonTestUtils.promiseStartupManager();
let id = "system-fileinstall@test";
let xpi = await AddonTestUtils.createTempWebExtensionFile({
manifest: {
applications: { gecko: { id } },
},
background() {
browser.test.sendMessage("started");
},
});
let wrapper = ExtensionTestUtils.expectExtension(id);
const install = await AddonManager.getInstallForFile(xpi, null, null, true);
install.install();
await wrapper.awaitStartup();
await wrapper.awaitMessage("started");
await promiseUninstall(id);
await AddonTestUtils.promiseShutdownManager();
});
add_task(async function test_system_profile_location_overridden() {
await AddonTestUtils.promiseStartupManager();
let id = "system-fileinstall@test";
let xpi = await AddonTestUtils.createTempWebExtensionFile({
manifest: {
version: "1.0",
applications: { gecko: { id } },
},
});
let install = await AddonManager.getInstallForFile(xpi, null, null, true);
await install.install();
let addon = await promiseAddonByID(id);
equal(addon.version, "1.0", "Addon is installed");
// Install a user profile version on top of the system profile location.
xpi = await AddonTestUtils.createTempWebExtensionFile({
manifest: {
version: "2.0",
applications: { gecko: { id } },
},
});
install = await AddonManager.getInstallForFile(xpi);
await install.install();
addon = await promiseAddonByID(id);
equal(addon.version, "2.0", "Addon is upgraded");
// Uninstall the system profile addon.
await AddonManager.uninstallSystemProfileAddon(id);
addon = await promiseAddonByID(id);
equal(addon.version, "2.0", "Addon is still active");
await addon.uninstall();
await AddonTestUtils.promiseShutdownManager();
});
add_task(async function test_system_profile_location_require_system_cert() {
await AddonTestUtils.promiseStartupManager();
let id = "fail@test";
let xpi = await AddonTestUtils.createTempWebExtensionFile({
manifest: {
applications: { gecko: { id } },
},
});
const install = await AddonManager.getInstallForURL(`file://${xpi.path}`, {
useSystemLocation: true, // KEY_APP_SYSTEM_PROFILE
});
await install.install();
let addon = await promiseAddonByID(id);
ok(!addon.isPrivileged, "Addon is not privileged");
ok(!addon.isActive, "Addon is not active");
equal(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED, "Addon is signed");
await addon.uninstall();
await AddonTestUtils.promiseShutdownManager();
});

Просмотреть файл

@ -79,15 +79,6 @@ async function promiseInstallProfileExtension(id, version, update_url) {
});
}
async function promiseInstallSystemProfileAddon(id, version) {
let xpi = createWebExtensionFile(id, version);
const install = await AddonManager.getInstallForURL(`file://${xpi.path}`, {
useSystemLocation: true, // KEY_APP_SYSTEM_PROFILE
});
return install.install();
}
async function promiseUpdateSystemAddon(id, version, waitForStartup = true) {
let xpi = createWebExtensionFile(id, version);
let xml = buildSystemAddonUpdates([
@ -147,8 +138,6 @@ async function checkAddon(version, reason, startReason = reason) {
* Upgrade to a system addon in the profile location, "app-system-addons"
* Upgrade to a temporary addon
* Uninstalling the temporary addon downgrades to the system addon in "app-system-addons".
* Upgrade to a system addon in the "app-system-profile" location.
* Uninstalling the "app-system-profile" addon downgrades to the one in "app-system-addons".
* Upgrade to a user-installed addon
* Upgrade the addon in "app-system-addons", verify user-install is still active
* Uninstall the addon in "app-system-addons", verify user-install is active
@ -181,18 +170,6 @@ async function _test_builtin_addon_override() {
await addon.uninstall();
await checkAddon("2.0", BOOTSTRAP_REASONS.ADDON_DOWNGRADE);
/////
// Install then uninstall an system profile addon
/////
info("Install an System Profile Addon, then uninstall it.");
await Promise.all([
promiseInstallSystemProfileAddon(ADDON_ID, "2.2"),
AddonTestUtils.promiseWebExtensionStartup(ADDON_ID),
]);
addon = await checkAddon("2.2", BOOTSTRAP_REASONS.ADDON_UPGRADE);
await addon.uninstall();
await checkAddon("2.0", BOOTSTRAP_REASONS.ADDON_DOWNGRADE);
/////
// Upgrade to a user-installed addon
/////

Просмотреть файл

@ -116,7 +116,6 @@ head = head_addons.js head_system_addons.js
[test_system_delay_update.js]
head = head_addons.js head_system_addons.js
skip-if = true # Bug 1495021
[test_system_profile_location.js]
[test_system_repository.js]
head = head_addons.js head_system_addons.js
[test_system_reset.js]