mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 857456 Part 4: Remove toolkit support for install.rdf r=kmag
--HG-- extra : rebase_source : b844d31e0e001376f1c25a9a555c8134d1e512ec extra : histedit_source : 83870efa70d1a0dc34e9e7bc3015aaa8c736de9f
This commit is contained in:
parent
d304bec8d7
commit
59d8cce642
@ -780,10 +780,6 @@ var AddonManagerInternal = {
|
||||
}
|
||||
}
|
||||
|
||||
// XXX temporary
|
||||
ChromeUtils.import("resource://gre/modules/addons/BootstrapLoader.jsm");
|
||||
AddonManager.addExternalExtensionLoader(BootstrapLoader);
|
||||
|
||||
// Load any providers registered in the category manager
|
||||
for (let {entry, value: url} of Services.catMan.enumerateCategory(CATEGORY_PROVIDER_MODULE)) {
|
||||
try {
|
||||
|
@ -849,9 +849,6 @@ var AddonTestUtils = {
|
||||
Cu.unload("resource://gre/modules/addons/XPIDatabase.jsm");
|
||||
Cu.unload("resource://gre/modules/addons/XPIInstall.jsm");
|
||||
|
||||
// XXX
|
||||
Cu.unload("resource://gre/modules/addons/BootstrapLoader.jsm");
|
||||
|
||||
let ExtensionScope = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
|
||||
ChromeUtils.defineModuleGetter(ExtensionScope, "XPIProvider",
|
||||
"resource://gre/modules/addons/XPIProvider.jsm");
|
||||
|
@ -1,363 +0,0 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["BootstrapLoader"];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
AddonInternal: "resource://gre/modules/addons/XPIDatabase.jsm",
|
||||
Blocklist: "resource://gre/modules/Blocklist.jsm",
|
||||
ConsoleAPI: "resource://gre/modules/Console.jsm",
|
||||
InstallRDF: "resource://gre/modules/addons/RDFManifestConverter.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "BOOTSTRAP_REASONS", () => {
|
||||
const {XPIProvider} = ChromeUtils.import("resource://gre/modules/addons/XPIProvider.jsm", {});
|
||||
return XPIProvider.BOOTSTRAP_REASONS;
|
||||
});
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Log.jsm");
|
||||
var logger = Log.repository.getLogger("addons.bootstrap");
|
||||
|
||||
/**
|
||||
* Valid IDs fit this pattern.
|
||||
*/
|
||||
var gIDTest = /^(\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}|[a-z0-9-\._]*\@[a-z0-9-\._]+)$/i;
|
||||
|
||||
// Properties that exist in the install manifest
|
||||
const PROP_METADATA = ["id", "version", "type", "internalName", "updateURL",
|
||||
"optionsURL", "optionsType", "aboutURL", "iconURL"];
|
||||
const PROP_LOCALE_SINGLE = ["name", "description", "creator", "homepageURL"];
|
||||
const PROP_LOCALE_MULTI = ["developers", "translators", "contributors"];
|
||||
|
||||
// Map new string type identifiers to old style nsIUpdateItem types.
|
||||
// Retired values:
|
||||
// 32 = multipackage xpi file
|
||||
// 8 = locale
|
||||
// 256 = apiextension
|
||||
// 128 = experiment
|
||||
// theme = 4
|
||||
const TYPES = {
|
||||
extension: 2,
|
||||
dictionary: 64,
|
||||
};
|
||||
|
||||
const COMPATIBLE_BY_DEFAULT_TYPES = {
|
||||
extension: true,
|
||||
dictionary: true,
|
||||
};
|
||||
|
||||
const hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty);
|
||||
|
||||
function isXPI(filename) {
|
||||
let ext = filename.slice(-4).toLowerCase();
|
||||
return ext === ".xpi" || ext === ".zip";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an nsIURI for a file within another file, either a directory or an XPI
|
||||
* file. If aFile is a directory then this will return a file: URI, if it is an
|
||||
* XPI file then it will return a jar: URI.
|
||||
*
|
||||
* @param {nsIFile} aFile
|
||||
* The file containing the resources, must be either a directory or an
|
||||
* XPI file
|
||||
* @param {string} aPath
|
||||
* The path to find the resource at, "/" separated. If aPath is empty
|
||||
* then the uri to the root of the contained files will be returned
|
||||
* @returns {nsIURI}
|
||||
* An nsIURI pointing at the resource
|
||||
*/
|
||||
function getURIForResourceInFile(aFile, aPath) {
|
||||
if (!isXPI(aFile.leafName)) {
|
||||
let resource = aFile.clone();
|
||||
if (aPath)
|
||||
aPath.split("/").forEach(part => resource.append(part));
|
||||
|
||||
return Services.io.newFileURI(resource);
|
||||
}
|
||||
|
||||
return buildJarURI(aFile, aPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a jar: URI for a file inside a ZIP file.
|
||||
*
|
||||
* @param {nsIFile} aJarfile
|
||||
* The ZIP file as an nsIFile
|
||||
* @param {string} aPath
|
||||
* The path inside the ZIP file
|
||||
* @returns {nsIURI}
|
||||
* An nsIURI for the file
|
||||
*/
|
||||
function buildJarURI(aJarfile, aPath) {
|
||||
let uri = Services.io.newFileURI(aJarfile);
|
||||
uri = "jar:" + uri.spec + "!/" + aPath;
|
||||
return Services.io.newURI(uri);
|
||||
}
|
||||
|
||||
var BootstrapLoader = {
|
||||
name: "bootstrap",
|
||||
manifestFile: "install.rdf",
|
||||
async loadManifest(pkg) {
|
||||
/**
|
||||
* Reads locale properties from either the main install manifest root or
|
||||
* an em:localized section in the install manifest.
|
||||
*
|
||||
* @param {Object} aSource
|
||||
* The resource to read the properties from.
|
||||
* @param {boolean} isDefault
|
||||
* True if the locale is to be read from the main install manifest
|
||||
* root
|
||||
* @param {string[]} aSeenLocales
|
||||
* An array of locale names already seen for this install manifest.
|
||||
* Any locale names seen as a part of this function will be added to
|
||||
* this array
|
||||
* @returns {Object}
|
||||
* an object containing the locale properties
|
||||
*/
|
||||
function readLocale(aSource, isDefault, aSeenLocales) {
|
||||
let locale = {};
|
||||
if (!isDefault) {
|
||||
locale.locales = [];
|
||||
for (let localeName of aSource.locales || []) {
|
||||
if (!localeName) {
|
||||
logger.warn("Ignoring empty locale in localized properties");
|
||||
continue;
|
||||
}
|
||||
if (aSeenLocales.includes(localeName)) {
|
||||
logger.warn("Ignoring duplicate locale in localized properties");
|
||||
continue;
|
||||
}
|
||||
aSeenLocales.push(localeName);
|
||||
locale.locales.push(localeName);
|
||||
}
|
||||
|
||||
if (locale.locales.length == 0) {
|
||||
logger.warn("Ignoring localized properties with no listed locales");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
for (let prop of [...PROP_LOCALE_SINGLE, ...PROP_LOCALE_MULTI]) {
|
||||
if (hasOwnProperty(aSource, prop)) {
|
||||
locale[prop] = aSource[prop];
|
||||
}
|
||||
}
|
||||
|
||||
return locale;
|
||||
}
|
||||
|
||||
let manifestData = await pkg.readString("install.rdf");
|
||||
let manifest = InstallRDF.loadFromString(manifestData).decode();
|
||||
|
||||
let addon = new AddonInternal();
|
||||
for (let prop of PROP_METADATA) {
|
||||
if (hasOwnProperty(manifest, prop)) {
|
||||
addon[prop] = manifest[prop];
|
||||
}
|
||||
}
|
||||
|
||||
if (!addon.type) {
|
||||
addon.type = "extension";
|
||||
} else {
|
||||
let type = addon.type;
|
||||
addon.type = null;
|
||||
for (let name in TYPES) {
|
||||
if (TYPES[name] == type) {
|
||||
addon.type = name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(addon.type in TYPES))
|
||||
throw new Error("Install manifest specifies unknown type: " + addon.type);
|
||||
|
||||
if (!addon.id)
|
||||
throw new Error("No ID in install manifest");
|
||||
if (!gIDTest.test(addon.id))
|
||||
throw new Error("Illegal add-on ID " + addon.id);
|
||||
if (!addon.version)
|
||||
throw new Error("No version in install manifest");
|
||||
|
||||
addon.strictCompatibility = (!(addon.type in COMPATIBLE_BY_DEFAULT_TYPES) ||
|
||||
manifest.strictCompatibility == "true");
|
||||
|
||||
// Only read these properties for extensions.
|
||||
if (addon.type == "extension") {
|
||||
if (manifest.bootstrap != "true") {
|
||||
throw new Error("Non-restartless extensions no longer supported");
|
||||
}
|
||||
|
||||
if (addon.optionsType &&
|
||||
addon.optionsType != AddonManager.OPTIONS_TYPE_INLINE_BROWSER &&
|
||||
addon.optionsType != AddonManager.OPTIONS_TYPE_TAB) {
|
||||
throw new Error("Install manifest specifies unknown optionsType: " + addon.optionsType);
|
||||
}
|
||||
} else {
|
||||
// Convert legacy dictionaries into a format the WebExtension
|
||||
// dictionary loader can process.
|
||||
if (addon.type === "dictionary") {
|
||||
addon.loader = null;
|
||||
let dictionaries = {};
|
||||
await pkg.iterFiles(({path}) => {
|
||||
let match = /^dictionaries\/([^\/]+)\.dic$/.exec(path);
|
||||
if (match) {
|
||||
let lang = match[1].replace(/_/g, "-");
|
||||
dictionaries[lang] = match[0];
|
||||
}
|
||||
});
|
||||
addon.startupData = {dictionaries};
|
||||
}
|
||||
|
||||
// Only extensions are allowed to provide an optionsURL, optionsType,
|
||||
// optionsBrowserStyle, or aboutURL. For all other types they are silently ignored
|
||||
addon.aboutURL = null;
|
||||
addon.optionsBrowserStyle = null;
|
||||
addon.optionsType = null;
|
||||
addon.optionsURL = null;
|
||||
}
|
||||
|
||||
addon.defaultLocale = readLocale(manifest, true);
|
||||
|
||||
let seenLocales = [];
|
||||
addon.locales = [];
|
||||
for (let localeData of manifest.localized || []) {
|
||||
let locale = readLocale(localeData, false, seenLocales);
|
||||
if (locale)
|
||||
addon.locales.push(locale);
|
||||
}
|
||||
|
||||
let dependencies = new Set(manifest.dependencies);
|
||||
addon.dependencies = Object.freeze(Array.from(dependencies));
|
||||
|
||||
let seenApplications = [];
|
||||
addon.targetApplications = [];
|
||||
for (let targetApp of manifest.targetApplications || []) {
|
||||
if (!targetApp.id || !targetApp.minVersion ||
|
||||
!targetApp.maxVersion) {
|
||||
logger.warn("Ignoring invalid targetApplication entry in install manifest");
|
||||
continue;
|
||||
}
|
||||
if (seenApplications.includes(targetApp.id)) {
|
||||
logger.warn("Ignoring duplicate targetApplication entry for " + targetApp.id +
|
||||
" in install manifest");
|
||||
continue;
|
||||
}
|
||||
seenApplications.push(targetApp.id);
|
||||
addon.targetApplications.push(targetApp);
|
||||
}
|
||||
|
||||
// Note that we don't need to check for duplicate targetPlatform entries since
|
||||
// the RDF service coalesces them for us.
|
||||
addon.targetPlatforms = [];
|
||||
for (let targetPlatform of manifest.targetPlatforms || []) {
|
||||
let platform = {
|
||||
os: null,
|
||||
abi: null,
|
||||
};
|
||||
|
||||
let pos = targetPlatform.indexOf("_");
|
||||
if (pos != -1) {
|
||||
platform.os = targetPlatform.substring(0, pos);
|
||||
platform.abi = targetPlatform.substring(pos + 1);
|
||||
} else {
|
||||
platform.os = targetPlatform;
|
||||
}
|
||||
|
||||
addon.targetPlatforms.push(platform);
|
||||
}
|
||||
|
||||
addon.userDisabled = false;
|
||||
addon.softDisabled = addon.blocklistState == Blocklist.STATE_SOFTBLOCKED;
|
||||
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
|
||||
|
||||
addon.userPermissions = null;
|
||||
|
||||
addon.icons = {};
|
||||
if (await pkg.hasResource("icon.png")) {
|
||||
addon.icons[32] = "icon.png";
|
||||
addon.icons[48] = "icon.png";
|
||||
}
|
||||
|
||||
if (await pkg.hasResource("icon64.png")) {
|
||||
addon.icons[64] = "icon64.png";
|
||||
}
|
||||
|
||||
return addon;
|
||||
},
|
||||
|
||||
loadScope(addon, file) {
|
||||
let uri = getURIForResourceInFile(file, "bootstrap.js").spec;
|
||||
let principal = Services.scriptSecurityManager.getSystemPrincipal();
|
||||
|
||||
let sandbox = new Cu.Sandbox(principal, {
|
||||
sandboxName: uri,
|
||||
addonId: addon.id,
|
||||
wantGlobalProperties: ["ChromeUtils"],
|
||||
metadata: { addonID: addon.id, URI: uri },
|
||||
});
|
||||
|
||||
try {
|
||||
Object.assign(sandbox, BOOTSTRAP_REASONS);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(sandbox, "console", () =>
|
||||
new ConsoleAPI({ consoleID: `addon/${addon.id}` }));
|
||||
|
||||
Services.scriptloader.loadSubScript(uri, sandbox);
|
||||
} catch (e) {
|
||||
logger.warn(`Error loading bootstrap.js for ${addon.id}`, e);
|
||||
}
|
||||
|
||||
function findMethod(name) {
|
||||
if (sandbox.name) {
|
||||
return sandbox.name;
|
||||
}
|
||||
|
||||
try {
|
||||
let method = Cu.evalInSandbox(name, sandbox);
|
||||
return method;
|
||||
} catch (err) { }
|
||||
|
||||
return () => {
|
||||
logger.warn(`Add-on ${addon.id} is missing bootstrap method ${name}`);
|
||||
};
|
||||
}
|
||||
|
||||
let install = findMethod("install");
|
||||
let uninstall = findMethod("uninstall");
|
||||
let startup = findMethod("startup");
|
||||
let shutdown = findMethod("shutdown");
|
||||
|
||||
return {
|
||||
install: (...args) => install(...args),
|
||||
uninstall: (...args) => uninstall(...args),
|
||||
|
||||
startup(...args) {
|
||||
if (addon.type == "extension") {
|
||||
logger.debug(`Registering manifest for ${file.path}\n`);
|
||||
Components.manager.addBootstrappedManifestLocation(file);
|
||||
}
|
||||
return startup(...args);
|
||||
},
|
||||
|
||||
shutdown(data, reason) {
|
||||
try {
|
||||
return shutdown(data, reason);
|
||||
} catch (err) {
|
||||
throw err;
|
||||
} finally {
|
||||
if (reason != BOOTSTRAP_REASONS.APP_SHUTDOWN) {
|
||||
logger.debug(`Removing manifest for ${file.path}\n`);
|
||||
Components.manager.removeBootstrappedManifestLocation(file);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["InstallRDF", "UpdateRDFConverter"];
|
||||
var EXPORTED_SYMBOLS = ["UpdateRDFConverter"];
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "RDFDataSource",
|
||||
"resource://gre/modules/addons/RDFDataSource.jsm");
|
||||
@ -16,8 +16,6 @@ const PREFIX_THEME = "urn:mozilla:theme:";
|
||||
|
||||
const TOOLKIT_ID = "toolkit@mozilla.org";
|
||||
|
||||
const RDFURI_INSTALL_MANIFEST_ROOT = "urn:mozilla:install-manifest";
|
||||
|
||||
function EM_R(aProperty) {
|
||||
return `http://www.mozilla.org/2004/em-rdf#${aProperty}`;
|
||||
}
|
||||
@ -52,75 +50,6 @@ class Manifest {
|
||||
}
|
||||
}
|
||||
|
||||
class InstallRDF extends Manifest {
|
||||
_readProps(source, obj, props) {
|
||||
for (let prop of props) {
|
||||
let val = getProperty(source, prop);
|
||||
if (val != null) {
|
||||
obj[prop] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_readArrayProp(source, obj, prop, target, decode = getValue) {
|
||||
let result = Array.from(source.getObjects(EM_R(prop)),
|
||||
target => decode(target));
|
||||
if (result.length) {
|
||||
obj[target] = result;
|
||||
}
|
||||
}
|
||||
|
||||
_readArrayProps(source, obj, props, decode = getValue) {
|
||||
for (let [prop, target] of Object.entries(props)) {
|
||||
this._readArrayProp(source, obj, prop, target, decode);
|
||||
}
|
||||
}
|
||||
|
||||
_readLocaleStrings(source, obj) {
|
||||
this._readProps(source, obj, ["name", "description", "creator", "homepageURL"]);
|
||||
this._readArrayProps(source, obj, {
|
||||
locale: "locales",
|
||||
developer: "developers",
|
||||
translator: "translators",
|
||||
contributor: "contributors",
|
||||
});
|
||||
}
|
||||
|
||||
decode() {
|
||||
let root = this.ds.getResource(RDFURI_INSTALL_MANIFEST_ROOT);
|
||||
let result = {};
|
||||
|
||||
let props = ["id", "version", "type", "updateURL", "optionsURL",
|
||||
"optionsType", "aboutURL", "iconURL",
|
||||
"bootstrap", "unpack", "strictCompatibility"];
|
||||
this._readProps(root, result, props);
|
||||
|
||||
let decodeTargetApplication = source => {
|
||||
let app = {};
|
||||
this._readProps(source, app, ["id", "minVersion", "maxVersion"]);
|
||||
return app;
|
||||
};
|
||||
|
||||
let decodeLocale = source => {
|
||||
let localized = {};
|
||||
this._readLocaleStrings(source, localized);
|
||||
return localized;
|
||||
};
|
||||
|
||||
this._readLocaleStrings(root, result);
|
||||
|
||||
this._readArrayProps(root, result, {"targetPlatform": "targetPlatforms"});
|
||||
this._readArrayProps(root, result, {"targetApplication": "targetApplications"},
|
||||
decodeTargetApplication);
|
||||
this._readArrayProps(root, result, {"localized": "localized"},
|
||||
decodeLocale);
|
||||
this._readArrayProps(root, result, {"dependency": "dependencies"},
|
||||
source => getProperty(source, "id"));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class UpdateRDF extends Manifest {
|
||||
decode() {
|
||||
let addons = {};
|
||||
|
@ -8,7 +8,6 @@ EXTRA_JS_MODULES.addons += [
|
||||
'AddonRepository.jsm',
|
||||
'AddonSettings.jsm',
|
||||
'AddonUpdateChecker.jsm',
|
||||
'BootstrapLoader.jsm',
|
||||
'Content.js',
|
||||
'GMPProvider.jsm',
|
||||
'LightweightThemeImageOptimizer.jsm',
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,27 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
|
||||
|
||||
const ADDONS = {
|
||||
test_bootstrap_const: {
|
||||
"install.rdf": {
|
||||
"id": "bootstrap@tests.mozilla.org",
|
||||
},
|
||||
"bootstrap.js": "ChromeUtils.import(\"resource://gre/modules/Services.jsm\");\n\nconst install = function() {\n Services.obs.notifyObservers(null, \"addon-install\");\n};\n",
|
||||
},
|
||||
};
|
||||
|
||||
add_task(async function() {
|
||||
await promiseStartupManager();
|
||||
|
||||
let sawInstall = false;
|
||||
Services.obs.addObserver(function() {
|
||||
sawInstall = true;
|
||||
}, "addon-install");
|
||||
|
||||
await AddonTestUtils.promiseInstallXPI(ADDONS.test_bootstrap_const);
|
||||
|
||||
ok(sawInstall);
|
||||
});
|
@ -1,66 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that bootstrap.js has the expected globals defined
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
|
||||
|
||||
const ADDONS = {
|
||||
bootstrap_globals: {
|
||||
"install.rdf": {
|
||||
"id": "bootstrap_globals@tests.mozilla.org",
|
||||
},
|
||||
"bootstrap.js": String.raw`ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var seenGlobals = new Set();
|
||||
var scope = this;
|
||||
function checkGlobal(name, type) {
|
||||
if (scope[name] && typeof(scope[name]) == type)
|
||||
seenGlobals.add(name);
|
||||
}
|
||||
|
||||
var wrapped = {};
|
||||
Services.obs.notifyObservers({ wrappedJSObject: wrapped }, "bootstrap-request-globals");
|
||||
for (let [name, type] of wrapped.expectedGlobals) {
|
||||
checkGlobal(name, type);
|
||||
}
|
||||
|
||||
function startup(data, reason) {
|
||||
Services.obs.notifyObservers({ wrappedJSObject: seenGlobals }, "bootstrap-seen-globals");
|
||||
}
|
||||
|
||||
function install(data, reason) {}
|
||||
function shutdown(data, reason) {}
|
||||
function uninstall(data, reason) {}
|
||||
`,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
const EXPECTED_GLOBALS = [
|
||||
["console", "object"],
|
||||
];
|
||||
|
||||
async function run_test() {
|
||||
do_test_pending();
|
||||
await promiseStartupManager();
|
||||
let sawGlobals = false;
|
||||
|
||||
Services.obs.addObserver(function(subject) {
|
||||
subject.wrappedJSObject.expectedGlobals = EXPECTED_GLOBALS;
|
||||
}, "bootstrap-request-globals");
|
||||
|
||||
Services.obs.addObserver(function({ wrappedJSObject: seenGlobals }) {
|
||||
for (let [name ] of EXPECTED_GLOBALS)
|
||||
Assert.ok(seenGlobals.has(name));
|
||||
|
||||
sawGlobals = true;
|
||||
}, "bootstrap-seen-globals");
|
||||
|
||||
await AddonTestUtils.promiseInstallXPI(ADDONS.bootstrap_globals);
|
||||
Assert.ok(sawGlobals);
|
||||
await promiseShutdownManager();
|
||||
do_test_finished();
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
const ADDON = {
|
||||
"install.rdf": {
|
||||
"id": "bug675371@tests.mozilla.org",
|
||||
},
|
||||
"chrome.manifest": `content bug675371 .`,
|
||||
"test.js": `var active = true;`,
|
||||
};
|
||||
|
||||
add_task(async function run_test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
await promiseStartupManager();
|
||||
});
|
||||
|
||||
function checkActive(expected) {
|
||||
let target = { active: false };
|
||||
let load = () => {
|
||||
Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
|
||||
};
|
||||
|
||||
if (expected) {
|
||||
load();
|
||||
} else {
|
||||
Assert.throws(load, /Error opening input stream/);
|
||||
}
|
||||
equal(target.active, expected, "Manifest is active?");
|
||||
}
|
||||
|
||||
add_task(async function test() {
|
||||
let {addon} = await AddonTestUtils.promiseInstallXPI(ADDON);
|
||||
|
||||
Assert.ok(addon.isActive);
|
||||
|
||||
// Tests that chrome.manifest is registered when the addon is installed.
|
||||
checkActive(true);
|
||||
|
||||
await addon.disable();
|
||||
checkActive(false);
|
||||
|
||||
await addon.enable();
|
||||
checkActive(true);
|
||||
|
||||
await promiseShutdownManager();
|
||||
|
||||
// Tests that chrome.manifest remains registered at app shutdown.
|
||||
checkActive(true);
|
||||
});
|
@ -1,113 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Test that side-loaded extensions with invalid install.rdf files are
|
||||
// not initialized at startup.
|
||||
|
||||
const APP_ID = "xpcshell@tests.mozilla.org";
|
||||
|
||||
Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_USER);
|
||||
|
||||
createAppInfo(APP_ID, "XPCShell", "1", "1.9.2");
|
||||
|
||||
const userAppDir = AddonTestUtils.profileDir.clone();
|
||||
userAppDir.append("app-extensions");
|
||||
userAppDir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
|
||||
AddonTestUtils.registerDirectory("XREUSysExt", userAppDir);
|
||||
|
||||
const userExtensions = userAppDir.clone();
|
||||
userExtensions.append(APP_ID);
|
||||
userExtensions.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetters(this, {
|
||||
ChromeRegistry: ["@mozilla.org/chrome/chrome-registry;1", "nsIChromeRegistry"],
|
||||
});
|
||||
|
||||
function hasChromeEntry(package) {
|
||||
try {
|
||||
void ChromeRegistry.convertChromeURL(Services.io.newURI(`chrome://${package}/content/`));
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
add_task(async function() {
|
||||
await promiseWriteInstallRDFToXPI({
|
||||
id: "langpack-foo@addons.mozilla.org",
|
||||
version: "1.0",
|
||||
type: 8,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Invalid install.rdf extension",
|
||||
}, userExtensions, undefined, {
|
||||
"chrome.manifest": `
|
||||
content foo-langpack ./
|
||||
`,
|
||||
});
|
||||
|
||||
await promiseWriteInstallRDFToXPI({
|
||||
id: "foo@addons.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Invalid install.rdf extension",
|
||||
}, userExtensions, undefined, {
|
||||
"chrome.manifest": `
|
||||
content foo ./
|
||||
`,
|
||||
});
|
||||
|
||||
await promiseWriteInstallRDFToXPI({
|
||||
id: "foo-legacy-legacy@addons.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: false,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Invalid install.rdf extension",
|
||||
}, userExtensions, undefined, {
|
||||
"chrome.manifest": `
|
||||
content foo-legacy-legacy ./
|
||||
`,
|
||||
});
|
||||
|
||||
equal(hasChromeEntry("foo-langpack"), false,
|
||||
"Should not have registered foo-langpack resource before AOM startup");
|
||||
equal(hasChromeEntry("foo-legacy-legacy"), false,
|
||||
"Should not have registered foo-legacy-legacy resource before AOM startup");
|
||||
equal(hasChromeEntry("foo"), false,
|
||||
"Should not have registered foo resource before AOM startup");
|
||||
|
||||
await promiseStartupManager();
|
||||
|
||||
equal(hasChromeEntry("foo-langpack"), false,
|
||||
"Should not have registered chrome manifest for invalid extension");
|
||||
equal(hasChromeEntry("foo-legacy-legacy"), false,
|
||||
"Should not have registered chrome manifest for non-restartless extension");
|
||||
equal(hasChromeEntry("foo"), true,
|
||||
"Should have registered chrome manifest for valid extension");
|
||||
|
||||
await promiseRestartManager();
|
||||
|
||||
equal(hasChromeEntry("foo-langpack"), false,
|
||||
"Should still not have registered chrome manifest for invalid extension after restart");
|
||||
equal(hasChromeEntry("foo-legacy-legacy"), false,
|
||||
"Should still not have registered chrome manifest for non-restartless extension");
|
||||
equal(hasChromeEntry("foo"), true,
|
||||
"Should still have registered chrome manifest for valid extension after restart");
|
||||
|
||||
await promiseShutdownManager();
|
||||
|
||||
userAppDir.remove(true);
|
||||
});
|
@ -1,118 +0,0 @@
|
||||
|
||||
const LEGACY_PREF = "extensions.legacy.enabled";
|
||||
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
|
||||
|
||||
add_task(async function test_disable() {
|
||||
await promiseStartupManager();
|
||||
|
||||
let legacy = [
|
||||
{
|
||||
id: "bootstrap@tests.mozilla.org",
|
||||
name: "Bootstrap add-on",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
},
|
||||
];
|
||||
|
||||
let nonLegacy = [
|
||||
{
|
||||
id: "webextension@tests.mozilla.org",
|
||||
manifest: {
|
||||
applications: {gecko: {id: "webextension@tests.mozilla.org"}},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "privileged@tests.mozilla.org",
|
||||
name: "Privileged Bootstrap add-on",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
},
|
||||
{
|
||||
id: "dictionary@tests.mozilla.org",
|
||||
name: "Test Dictionary",
|
||||
version: "1.0",
|
||||
type: "64",
|
||||
},
|
||||
];
|
||||
|
||||
function makeXPI(info) {
|
||||
if (info.manifest) {
|
||||
return createTempWebExtensionFile(info);
|
||||
}
|
||||
|
||||
return createTempXPIFile(Object.assign({}, info, {
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
}));
|
||||
}
|
||||
|
||||
AddonTestUtils.usePrivilegedSignatures = id => id.startsWith("privileged");
|
||||
|
||||
// Start out with legacy extensions disabled, installing non-legacy
|
||||
// extensions should succeed.
|
||||
Services.prefs.setBoolPref(LEGACY_PREF, false);
|
||||
let installs = await Promise.all(nonLegacy.map(info => {
|
||||
let xpi = makeXPI(info);
|
||||
return AddonManager.getInstallForFile(xpi);
|
||||
}));
|
||||
await promiseCompleteAllInstalls(installs);
|
||||
for (let install of installs) {
|
||||
Assert.equal(install.state, AddonManager.STATE_INSTALLED);
|
||||
Assert.equal(install.error, 0);
|
||||
}
|
||||
let addons = await AddonManager.getAddonsByIDs(nonLegacy.map(a => a.id));
|
||||
for (let addon of addons) {
|
||||
Assert.equal(addon.appDisabled, false);
|
||||
}
|
||||
|
||||
// And installing legacy extensions should fail
|
||||
let legacyXPIs = legacy.map(makeXPI);
|
||||
installs = await Promise.all(legacyXPIs.map(xpi => AddonManager.getInstallForFile(xpi)));
|
||||
|
||||
// Yuck, the AddonInstall API is atrocious. Installs of incompatible
|
||||
// extensions are detected when the install reaches the DOWNLOADED state
|
||||
// and the install is abandoned at that point. Since this is a local file
|
||||
// install we just start out in the DOWNLOADED state.
|
||||
for (let install of installs) {
|
||||
Assert.equal(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
Assert.equal(install.addon.appDisabled, true);
|
||||
}
|
||||
|
||||
// Now enable legacy extensions, and we should be able to install
|
||||
// the legacy extensions.
|
||||
Services.prefs.setBoolPref(LEGACY_PREF, true);
|
||||
installs = await Promise.all(legacyXPIs.map(xpi => AddonManager.getInstallForFile(xpi)));
|
||||
for (let install of installs) {
|
||||
Assert.equal(install.state, AddonManager.STATE_DOWNLOADED);
|
||||
Assert.equal(install.addon.appDisabled, false);
|
||||
}
|
||||
await promiseCompleteAllInstalls(installs);
|
||||
for (let install of installs) {
|
||||
Assert.equal(install.state, AddonManager.STATE_INSTALLED);
|
||||
Assert.equal(install.error, 0);
|
||||
}
|
||||
addons = await AddonManager.getAddonsByIDs(legacy.map(a => a.id));
|
||||
for (let addon of addons) {
|
||||
Assert.equal(addon.appDisabled, false);
|
||||
}
|
||||
|
||||
// Flip the preference back, the legacy extensions should become disabled
|
||||
// but non-legacy extensions should remain enabled.
|
||||
Services.prefs.setBoolPref(LEGACY_PREF, false);
|
||||
addons = await AddonManager.getAddonsByIDs(nonLegacy.map(a => a.id));
|
||||
for (let addon of addons) {
|
||||
Assert.equal(addon.appDisabled, false);
|
||||
await addon.uninstall();
|
||||
}
|
||||
addons = await AddonManager.getAddonsByIDs(legacy.map(a => a.id));
|
||||
for (let addon of addons) {
|
||||
Assert.equal(addon.appDisabled, true);
|
||||
await addon.uninstall();
|
||||
}
|
||||
|
||||
Services.prefs.clearUserPref(LEGACY_PREF);
|
||||
});
|
@ -1,752 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This tests that all properties are read from the install manifests and that
|
||||
// items are correctly enabled/disabled based on them (blocklist tests are
|
||||
// elsewhere)
|
||||
|
||||
const ADDONS = [
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
aboutURL: "chrome://test/content/about.xul",
|
||||
iconURL: "chrome://test/skin/icon.png",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 1",
|
||||
description: "Test Description",
|
||||
creator: "Test Creator",
|
||||
homepageURL: "http://www.example.com",
|
||||
developer: [
|
||||
"Test Developer 1",
|
||||
"Test Developer 2",
|
||||
],
|
||||
translator: [
|
||||
"Test Translator 1",
|
||||
"Test Translator 2",
|
||||
],
|
||||
contributor: [
|
||||
"Test Contributor 1",
|
||||
"Test Contributor 2",
|
||||
],
|
||||
},
|
||||
|
||||
expected: {
|
||||
id: "addon1@tests.mozilla.org",
|
||||
type: "extension",
|
||||
version: "1.0",
|
||||
optionsType: null,
|
||||
aboutURL: "chrome://test/content/about.xul",
|
||||
iconURL: "chrome://test/skin/icon.png",
|
||||
icons: {32: "chrome://test/skin/icon.png", 48: "chrome://test/skin/icon.png"},
|
||||
name: "Test Addon 1",
|
||||
description: "Test Description",
|
||||
creator: "Test Creator",
|
||||
homepageURL: "http://www.example.com",
|
||||
developers: ["Test Developer 1", "Test Developer 2"],
|
||||
translators: ["Test Translator 1", "Test Translator 2"],
|
||||
contributors: ["Test Contributor 1", "Test Contributor 2"],
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
providesUpdatesSecurely: true,
|
||||
blocklistState: Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon2@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
updateURL: "https://www.foo.com",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 2",
|
||||
},
|
||||
|
||||
expected: {
|
||||
id: "addon2@tests.mozilla.org",
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
providesUpdatesSecurely: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon3@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
updateURL: "http://www.foo.com",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 3",
|
||||
},
|
||||
|
||||
expected: {
|
||||
id: "addon3@tests.mozilla.org",
|
||||
isActive: false,
|
||||
userDisabled: false,
|
||||
appDisabled: true,
|
||||
providesUpdatesSecurely: false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon4@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
updateURL: "http://www.foo.com",
|
||||
updateKey: "foo",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 4",
|
||||
},
|
||||
|
||||
expected: {
|
||||
id: "addon4@tests.mozilla.org",
|
||||
isActive: false,
|
||||
userDisabled: false,
|
||||
appDisabled: true,
|
||||
providesUpdatesSecurely: false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon5@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "*",
|
||||
}],
|
||||
name: "Test Addon 5",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon6@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "0",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 6",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon7@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "0",
|
||||
maxVersion: "0",
|
||||
}],
|
||||
name: "Test Addon 7",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: false,
|
||||
userDisabled: false,
|
||||
appDisabled: true,
|
||||
isCompatible: false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon8@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1.1",
|
||||
maxVersion: "*",
|
||||
}],
|
||||
name: "Test Addon 8",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: false,
|
||||
userDisabled: false,
|
||||
appDisabled: true,
|
||||
isCompatible: false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon9@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9.2",
|
||||
maxVersion: "1.9.*",
|
||||
}],
|
||||
name: "Test Addon 9",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon10@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9.2.1",
|
||||
maxVersion: "1.9.*",
|
||||
}],
|
||||
name: "Test Addon 10",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: false,
|
||||
userDisabled: false,
|
||||
appDisabled: true,
|
||||
isCompatible: false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon11@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9",
|
||||
maxVersion: "1.9.2",
|
||||
}],
|
||||
name: "Test Addon 11",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon12@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9",
|
||||
maxVersion: "1.9.1.*",
|
||||
}],
|
||||
name: "Test Addon 12",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: false,
|
||||
userDisabled: false,
|
||||
appDisabled: true,
|
||||
isCompatible: false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon13@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9",
|
||||
maxVersion: "1.9.*",
|
||||
}, {
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "0",
|
||||
maxVersion: "0.5",
|
||||
}],
|
||||
name: "Test Addon 13",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: false,
|
||||
userDisabled: false,
|
||||
appDisabled: true,
|
||||
isCompatible: false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon14@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "toolkit@mozilla.org",
|
||||
minVersion: "1.9",
|
||||
maxVersion: "1.9.1",
|
||||
}, {
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 14",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon15@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
updateKey: "foo",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 15",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
providesUpdatesSecurely: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon16@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
updateKey: "foo",
|
||||
updateURL: "https://www.foo.com",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 16",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
providesUpdatesSecurely: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon17@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
optionsURL: "chrome://test/content/options.xul",
|
||||
optionsType: "2",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 17",
|
||||
},
|
||||
|
||||
// An obsolete optionsType means the add-on isn't registered.
|
||||
expected: null,
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon18@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 18",
|
||||
},
|
||||
extraFiles: {"options.xul": ""},
|
||||
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
optionsURL: null,
|
||||
optionsType: null,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon19@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
optionsType: "99",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 19",
|
||||
},
|
||||
|
||||
expected: null,
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon20@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
optionsURL: "chrome://test/content/options.xul",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 20",
|
||||
},
|
||||
|
||||
// Even with a defined optionsURL optionsType is null by default.
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
optionsURL: "chrome://test/content/options.xul",
|
||||
optionsType: null,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon21@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
optionsType: "3",
|
||||
optionsURL: "chrome://test/content/options.xul",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 21",
|
||||
},
|
||||
|
||||
expected: {
|
||||
isActive: true,
|
||||
userDisabled: false,
|
||||
appDisabled: false,
|
||||
isCompatible: true,
|
||||
optionsURL: "chrome://test/content/options.xul",
|
||||
optionsType: AddonManager.OPTIONS_TYPE_TAB,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon22@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
optionsType: "2",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 22",
|
||||
},
|
||||
|
||||
// An obsolete optionsType means the add-on isn't registered.
|
||||
expected: null,
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon23@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
optionsType: "2",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 23",
|
||||
},
|
||||
extraFiles: {"options.xul": ""},
|
||||
|
||||
// An obsolete optionsType means the add-on isn't registered.
|
||||
expected: null,
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon24@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 24",
|
||||
},
|
||||
extraFiles: {"options.xul": ""},
|
||||
|
||||
expected: {
|
||||
optionsType: null,
|
||||
optionsURL: null,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon25@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
optionsType: "3",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 25",
|
||||
},
|
||||
|
||||
expected: {
|
||||
optionsType: null,
|
||||
optionsURL: null,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "addon26@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
optionsType: "4",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
name: "Test Addon 26",
|
||||
},
|
||||
extraFiles: {"options.xul": ""},
|
||||
expected: null,
|
||||
},
|
||||
|
||||
// Tests compatibility based on target platforms.
|
||||
|
||||
// No targetPlatforms so should be compatible
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "tp-addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
name: "Test 1",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
},
|
||||
|
||||
expected: {
|
||||
appDisabled: false,
|
||||
isPlatformCompatible: true,
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
|
||||
// Matches the OS
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "tp-addon2@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
name: "Test 2",
|
||||
targetPlatforms: [
|
||||
"XPCShell",
|
||||
"WINNT_x86",
|
||||
"XPCShell",
|
||||
],
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
},
|
||||
|
||||
expected: {
|
||||
appDisabled: false,
|
||||
isPlatformCompatible: true,
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
|
||||
// Matches the OS and ABI
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "tp-addon3@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
name: "Test 3",
|
||||
targetPlatforms: [
|
||||
"WINNT",
|
||||
"XPCShell_noarch-spidermonkey",
|
||||
],
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
},
|
||||
|
||||
expected: {
|
||||
appDisabled: false,
|
||||
isPlatformCompatible: true,
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
|
||||
// Doesn't match
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "tp-addon4@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
name: "Test 4",
|
||||
targetPlatforms: [
|
||||
"WINNT_noarch-spidermonkey",
|
||||
"Darwin",
|
||||
"WINNT_noarch-spidermonkey",
|
||||
],
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
},
|
||||
|
||||
expected: {
|
||||
appDisabled: true,
|
||||
isPlatformCompatible: false,
|
||||
isActive: false,
|
||||
},
|
||||
},
|
||||
|
||||
// Matches the OS but since a different entry specifies ABI this doesn't match.
|
||||
{
|
||||
"install.rdf": {
|
||||
id: "tp-addon5@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
bootstrap: true,
|
||||
name: "Test 5",
|
||||
targetPlatforms: [
|
||||
"XPCShell",
|
||||
"XPCShell_foo",
|
||||
],
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1",
|
||||
}],
|
||||
},
|
||||
|
||||
expected: {
|
||||
appDisabled: true,
|
||||
isPlatformCompatible: false,
|
||||
isActive: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const IDS = ADDONS.map(a => a["install.rdf"].id);
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
for (let addon of ADDONS) {
|
||||
await promiseWriteInstallRDFForExtension(addon["install.rdf"], profileDir, undefined, addon.extraFiles);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_values() {
|
||||
await promiseStartupManager();
|
||||
|
||||
let addons = await getAddons(IDS);
|
||||
|
||||
for (let addon of ADDONS) {
|
||||
let {id} = addon["install.rdf"];
|
||||
checkAddon(id, addons.get(id), addon.expected);
|
||||
}
|
||||
|
||||
await promiseShutdownManager();
|
||||
});
|
@ -1,134 +0,0 @@
|
||||
/* 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/.
|
||||
*/
|
||||
|
||||
const ID = "bug397778@tests.mozilla.org";
|
||||
|
||||
const ADDON = {
|
||||
id: "bug397778@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Fallback Name",
|
||||
description: "Fallback Description",
|
||||
bootstrap: true,
|
||||
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"}],
|
||||
|
||||
localized: [
|
||||
{
|
||||
locale: ["fr"],
|
||||
name: "fr Name",
|
||||
description: "fr Description",
|
||||
},
|
||||
{
|
||||
locale: ["de-DE"],
|
||||
name: "Deutsches W\u00f6rterbuch",
|
||||
},
|
||||
{
|
||||
locale: ["es-ES"],
|
||||
name: "es-ES Name",
|
||||
description: "es-ES Description",
|
||||
},
|
||||
{
|
||||
locale: ["zh-TW"],
|
||||
name: "zh-TW Name",
|
||||
description: "zh-TW Description",
|
||||
},
|
||||
{
|
||||
locale: ["zh-CN"],
|
||||
name: "zh-CN Name",
|
||||
description: "zh-CN Description",
|
||||
},
|
||||
{
|
||||
locale: ["en-GB"],
|
||||
name: "en-GB Name",
|
||||
description: "en-GB Description",
|
||||
},
|
||||
{
|
||||
locale: ["en"],
|
||||
name: "en Name",
|
||||
description: "en Description",
|
||||
},
|
||||
{
|
||||
locale: ["en-CA"],
|
||||
name: "en-CA Name",
|
||||
description: "en-CA Description",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1");
|
||||
Services.locale.requestedLocales = ["fr-FR"];
|
||||
|
||||
await promiseStartupManager();
|
||||
await promiseInstallXPI(ADDON);
|
||||
});
|
||||
|
||||
add_task(async function test_1() {
|
||||
let addon = await AddonManager.getAddonByID(ID);
|
||||
Assert.notEqual(addon, null);
|
||||
Assert.equal(addon.name, "fr Name");
|
||||
Assert.equal(addon.description, "fr Description");
|
||||
|
||||
await addon.disable();
|
||||
await promiseRestartManager();
|
||||
|
||||
let newAddon = await AddonManager.getAddonByID(ID);
|
||||
Assert.notEqual(newAddon, null);
|
||||
Assert.equal(newAddon.name, "fr Name");
|
||||
});
|
||||
|
||||
add_task(async function test_2() {
|
||||
// Change locale. The more specific de-DE is the best match
|
||||
await restartWithLocales(["de"]);
|
||||
|
||||
let addon = await AddonManager.getAddonByID(ID);
|
||||
Assert.notEqual(addon, null);
|
||||
Assert.equal(addon.name, "Deutsches W\u00f6rterbuch");
|
||||
Assert.equal(addon.description, null);
|
||||
});
|
||||
|
||||
add_task(async function test_3() {
|
||||
// Change locale. Locale case should have no effect
|
||||
await restartWithLocales(["DE-de"]);
|
||||
|
||||
let addon = await AddonManager.getAddonByID(ID);
|
||||
Assert.notEqual(addon, null);
|
||||
Assert.equal(addon.name, "Deutsches W\u00f6rterbuch");
|
||||
Assert.equal(addon.description, null);
|
||||
});
|
||||
|
||||
add_task(async function test_4() {
|
||||
// Change locale. es-ES should closely match
|
||||
await restartWithLocales(["es-AR"]);
|
||||
|
||||
let addon = await AddonManager.getAddonByID(ID);
|
||||
Assert.notEqual(addon, null);
|
||||
Assert.equal(addon.name, "es-ES Name");
|
||||
Assert.equal(addon.description, "es-ES Description");
|
||||
});
|
||||
|
||||
add_task(async function test_5() {
|
||||
// Change locale. Either zh-CN or zh-TW could match
|
||||
await restartWithLocales(["zh"]);
|
||||
|
||||
let addon = await AddonManager.getAddonByID(ID);
|
||||
Assert.notEqual(addon, null);
|
||||
ok(addon.name == "zh-TW Name" || addon.name == "zh-CN Name",
|
||||
`Add-on name mismatch: ${addon.name}`);
|
||||
});
|
||||
|
||||
add_task(async function test_6() {
|
||||
// Unknown locale should try to match against en-US as well. Of en,en-GB
|
||||
// en should match as being less specific
|
||||
await restartWithLocales(["nl-NL"]);
|
||||
|
||||
let addon = await AddonManager.getAddonByID(ID);
|
||||
Assert.notEqual(addon, null);
|
||||
Assert.equal(addon.name, "en Name");
|
||||
Assert.equal(addon.description, "en Description");
|
||||
});
|
@ -63,10 +63,6 @@ tags = blocklist
|
||||
# Times out during parallel runs on desktop
|
||||
requesttimeoutfactor = 2
|
||||
tags = blocklist
|
||||
[test_bootstrap.js]
|
||||
[test_bootstrap_const.js]
|
||||
[test_bootstrap_globals.js]
|
||||
[test_bootstrapped_chrome_manifest.js]
|
||||
[test_cache_certdb.js]
|
||||
[test_cacheflush.js]
|
||||
[test_childprocess.js]
|
||||
@ -134,17 +130,10 @@ skip-if = appname != "firefox"
|
||||
[test_install_icons.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_invalid_install_rdf.js]
|
||||
[test_isDebuggable.js]
|
||||
[test_isReady.js]
|
||||
[test_json_updatecheck.js]
|
||||
[test_legacy.js]
|
||||
skip-if = !allow_legacy_extensions || appname == "thunderbird"
|
||||
[test_locale.js]
|
||||
[test_manifest.js]
|
||||
[test_manifest_locales.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_moved_extension_metadata.js]
|
||||
skip-if = true
|
||||
[test_no_addons.js]
|
||||
|
Loading…
Reference in New Issue
Block a user