Bug 1446868: Part 1 - Preprocess RDF update manifests into JSON format. r=aswan

MozReview-Commit-ID: 4r5OubGG8Ci

--HG--
extra : rebase_source : 51a205dc36cedc6da977e504a53ba39be2d8009b
This commit is contained in:
Kris Maglione 2018-03-18 21:24:53 -07:00
Родитель 98aba60038
Коммит 0257b6847c
35 изменённых файлов: 716 добавлений и 1229 удалений

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

@ -12,13 +12,7 @@
var EXPORTED_SYMBOLS = [ "AddonUpdateChecker" ];
const TIMEOUT = 60 * 1000;
const PREFIX_NS_RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#";
const PREFIX_ITEM = "urn:mozilla:item:";
const PREFIX_EXTENSION = "urn:mozilla:extension:";
const PREFIX_THEME = "urn:mozilla:theme:";
const TOOLKIT_ID = "toolkit@mozilla.org";
const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/parsererror.xml";
const PREF_UPDATE_REQUIREBUILTINCERTS = "extensions.update.requireBuiltInCerts";
@ -33,6 +27,8 @@ ChromeUtils.defineModuleGetter(this, "AddonRepository",
"resource://gre/modules/addons/AddonRepository.jsm");
ChromeUtils.defineModuleGetter(this, "ServiceRequest",
"resource://gre/modules/ServiceRequest.jsm");
ChromeUtils.defineModuleGetter(this, "UpdateRDFConverter",
"resource://gre/modules/addons/UpdateRDFConverter.jsm");
// Shared code for suppressing bad cert dialogs.
@ -42,9 +38,6 @@ XPCOMUtils.defineLazyGetter(this, "CertUtils", function() {
return certUtils;
});
var gRDF = Cc["@mozilla.org/rdf/rdf-service;1"].
getService(Ci.nsIRDFService);
ChromeUtils.import("resource://gre/modules/Log.jsm");
const LOGGER_ID = "addons.update-checker";
@ -94,140 +87,6 @@ function sanitizeUpdateURL(aUpdate, aRequest, aHashPattern, aHashString) {
}
}
/**
* Parses an RDF style update manifest into an array of update objects.
*
* @param aId
* The ID of the add-on being checked for updates
* @param aRequest
* The XMLHttpRequest that has retrieved the update manifest
* @param aManifestData
* The pre-parsed manifest, as a bare XML DOM document
* @return an array of update objects
* @throws if the update manifest is invalid in any way
*/
function parseRDFManifest(aId, aRequest, aManifestData) {
if (aManifestData.documentElement.namespaceURI != PREFIX_NS_RDF) {
throw Components.Exception("Update manifest had an unrecognised namespace: " +
aManifestData.documentElement.namespaceURI);
}
function EM_R(aProp) {
return gRDF.GetResource(PREFIX_NS_EM + aProp);
}
function getValue(aLiteral) {
if (aLiteral instanceof Ci.nsIRDFLiteral)
return aLiteral.Value;
if (aLiteral instanceof Ci.nsIRDFResource)
return aLiteral.Value;
if (aLiteral instanceof Ci.nsIRDFInt)
return aLiteral.Value;
return null;
}
function getProperty(aDs, aSource, aProperty) {
return getValue(aDs.GetTarget(aSource, EM_R(aProperty), true));
}
function getBooleanProperty(aDs, aSource, aProperty) {
let propValue = aDs.GetTarget(aSource, EM_R(aProperty), true);
if (!propValue)
return undefined;
return getValue(propValue) == "true";
}
function getRequiredProperty(aDs, aSource, aProperty) {
let value = getProperty(aDs, aSource, aProperty);
if (!value)
throw Components.Exception("Update manifest is missing a required " + aProperty + " property.");
return value;
}
let rdfParser = Cc["@mozilla.org/rdf/xml-parser;1"].
createInstance(Ci.nsIRDFXMLParser);
let ds = Cc["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
createInstance(Ci.nsIRDFDataSource);
rdfParser.parseString(ds, aRequest.channel.URI, aRequest.responseText);
// Differentiating between add-on types is deprecated
let extensionRes = gRDF.GetResource(PREFIX_EXTENSION + aId);
let themeRes = gRDF.GetResource(PREFIX_THEME + aId);
let itemRes = gRDF.GetResource(PREFIX_ITEM + aId);
let addonRes;
if (ds.ArcLabelsOut(extensionRes).hasMoreElements())
addonRes = extensionRes;
else if (ds.ArcLabelsOut(themeRes).hasMoreElements())
addonRes = themeRes;
else
addonRes = itemRes;
let updates = ds.GetTarget(addonRes, EM_R("updates"), true);
// A missing updates property doesn't count as a failure, just as no avialable
// update information
if (!updates) {
logger.warn("Update manifest for " + aId + " did not contain an updates property");
return [];
}
if (!(updates instanceof Ci.nsIRDFResource))
throw Components.Exception("Missing updates property for " + addonRes.Value);
let cu = Cc["@mozilla.org/rdf/container-utils;1"].
getService(Ci.nsIRDFContainerUtils);
if (!cu.IsContainer(ds, updates))
throw Components.Exception("Updates property was not an RDF container");
let results = [];
let ctr = Cc["@mozilla.org/rdf/container;1"].
createInstance(Ci.nsIRDFContainer);
ctr.Init(ds, updates);
let items = ctr.GetElements();
while (items.hasMoreElements()) {
let item = items.getNext().QueryInterface(Ci.nsIRDFResource);
let version = getProperty(ds, item, "version");
if (!version) {
logger.warn("Update manifest is missing a required version property.");
continue;
}
logger.debug("Found an update entry for " + aId + " version " + version);
let targetApps = ds.GetTargets(item, EM_R("targetApplication"), true);
while (targetApps.hasMoreElements()) {
let targetApp = targetApps.getNext().QueryInterface(Ci.nsIRDFResource);
let appEntry = {};
try {
appEntry.id = getRequiredProperty(ds, targetApp, "id");
appEntry.minVersion = getRequiredProperty(ds, targetApp, "minVersion");
appEntry.maxVersion = getRequiredProperty(ds, targetApp, "maxVersion");
} catch (e) {
logger.warn(e);
continue;
}
let result = {
id: aId,
version,
updateURL: getProperty(ds, targetApp, "updateLink"),
updateHash: getProperty(ds, targetApp, "updateHash"),
updateInfoURL: getProperty(ds, targetApp, "updateInfoURL"),
strictCompatibility: !!getBooleanProperty(ds, targetApp, "strictCompatibility"),
targetApplications: [appEntry]
};
// The JSON update protocol requires an SHA-2 hash. RDF still
// supports SHA-1, for compatibility reasons.
sanitizeUpdateURL(result, aRequest, /^sha/, "sha1 or stronger");
results.push(result);
}
}
return results;
}
/**
* Parses an JSON update manifest into an array of update objects.
*
@ -335,6 +194,16 @@ function parseJSONManifest(aId, aRequest, aManifestData) {
appEntry.maxVersion = getProperty(app, "advisory_max_version", "string");
}
// Add an app entry for the current API ID, too, so that it overrides any
// existing app-specific entries, which would take priority over the toolkit
// entry.
//
// Note: This currently only has any effect on legacy extensions (mainly
// those used in tests), since WebExtensions cannot yet specify app-specific
// compatibility ranges.
result.targetApplications.push(Object.assign({}, appEntry,
{id: Services.appinfo.ID}));
// The JSON update protocol requires an SHA-2 hash. RDF still
// supports SHA-1, for compatibility reasons.
sanitizeUpdateURL(result, aRequest, /^sha(256|512):/, "sha256 or sha512");
@ -422,22 +291,16 @@ UpdateParser.prototype = {
// Detect the manifest type by first attempting to parse it as
// JSON, and falling back to parsing it as XML if that fails.
let parser;
let json;
try {
try {
let json = JSON.parse(request.responseText);
let data = request.responseText;
if (data.startsWith("<?xml")) {
logger.warn(`${this.url}: RDF update manifests are deprecated, ` +
"and support will soon be removed");
parser = () => parseJSONManifest(this.id, request, json);
} catch (e) {
if (!(e instanceof SyntaxError))
throw e;
let domParser = Cc["@mozilla.org/xmlextras/domparser;1"].createInstance(Ci.nsIDOMParser);
let xml = domParser.parseFromString(request.responseText, "text/xml");
if (xml.documentElement.namespaceURI == XMLURI_PARSE_ERROR)
throw new Error("Update manifest was not valid XML or JSON");
parser = () => parseRDFManifest(this.id, request, xml);
json = UpdateRDFConverter.convertToJSON(request);
} else {
json = JSON.parse(data);
}
} catch (e) {
logger.warn("onUpdateCheckComplete failed to determine manifest type");
@ -447,7 +310,7 @@ UpdateParser.prototype = {
let results;
try {
results = parser();
results = parseJSONManifest(this.id, request, json);
} catch (e) {
logger.warn("onUpdateCheckComplete failed to parse update manifest", e);
this.notifyError(AddonManager.ERROR_PARSE_ERROR);

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

@ -0,0 +1,159 @@
/* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["UpdateRDFConverter"];
const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#";
const PREFIX_ITEM = "urn:mozilla:item:";
const PREFIX_EXTENSION = "urn:mozilla:extension:";
const PREFIX_THEME = "urn:mozilla:theme:";
const TOOLKIT_ID = "toolkit@mozilla.org";
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyServiceGetters(this, {
gRDF: ["@mozilla.org/rdf/rdf-service;1", "nsIRDFService"],
containerUtils: ["@mozilla.org/rdf/container-utils;1", "nsIRDFContainerUtils"],
});
const RDFContainer = Components.Constructor(
"@mozilla.org/rdf/container;1", "nsIRDFContainer", "Init");
const RDFDataSource = Components.Constructor(
"@mozilla.org/rdf/datasource;1?name=in-memory-datasource", "nsIRDFDataSource");
const RDFParser = Components.Constructor(
"@mozilla.org/rdf/xml-parser;1", "nsIRDFXMLParser");
/**
* Parses an RDF style update manifest into a JSON-style update
* manifest.
*
* @param {XMLHttpRequest> aRequest
* The XMLHttpRequest that has retrieved the update manifest
* @returns {object} a JSON update manifest.
*/
function parseRDFManifest(aRequest) {
function EM_R(aProp) {
return gRDF.GetResource(PREFIX_NS_EM + aProp);
}
function getValue(aLiteral) {
if (aLiteral instanceof Ci.nsIRDFLiteral)
return aLiteral.Value;
if (aLiteral instanceof Ci.nsIRDFResource)
return aLiteral.Value;
if (aLiteral instanceof Ci.nsIRDFInt)
return aLiteral.Value;
return null;
}
function getProperty(aDs, aSource, aProperty) {
return getValue(aDs.GetTarget(aSource, EM_R(aProperty), true));
}
function getBooleanProperty(aDs, aSource, aProperty) {
let propValue = aDs.GetTarget(aSource, EM_R(aProperty), true);
if (!propValue)
return undefined;
return getValue(propValue) == "true";
}
let rdfParser = new RDFParser();
let ds = new RDFDataSource();
rdfParser.parseString(ds, aRequest.channel.URI, aRequest.responseText);
let addons = {};
let result = {addons};
for (let addonRes of XPCOMUtils.IterSimpleEnumerator(ds.GetAllResources(), Ci.nsIRDFResource)) {
let value = addonRes.ValueUTF8;
let id;
for (let prefix of [PREFIX_EXTENSION, PREFIX_THEME, PREFIX_ITEM]) {
if (value.startsWith(prefix)) {
id = value.substr(prefix.length);
break;
}
}
if (!id) {
continue;
}
let addon = {};
addons[id] = addon;
let updatesTarget = ds.GetTarget(addonRes, EM_R("updates"), true);
if (!(updatesTarget instanceof Ci.nsIRDFResource) ||
!containerUtils.IsContainer(ds, updatesTarget)) {
continue;
}
let updates = [];
addon.updates = updates;
let ctr = new RDFContainer(ds, updatesTarget);
for (let item of XPCOMUtils.IterSimpleEnumerator(ctr.GetElements(),
Ci.nsIRDFResource)) {
let version = getProperty(ds, item, "version");
let targetApps = ds.GetTargets(item, EM_R("targetApplication"), true);
for (let targetApp of XPCOMUtils.IterSimpleEnumerator(targetApps,
Ci.nsIRDFResource)) {
let appEntry = {};
let minVersion = getProperty(ds, targetApp, "minVersion");
if (minVersion) {
appEntry.strict_min_version = minVersion;
}
let maxVersion = getProperty(ds, targetApp, "maxVersion");
if (maxVersion) {
if (getBooleanProperty(ds, targetApp, "strictCompatibility")) {
appEntry.strict_max_version = maxVersion;
} else {
appEntry.advisory_max_version = maxVersion;
}
}
let appId = getProperty(ds, targetApp, "id");
if (!appId) {
continue;
}
if (appId === TOOLKIT_ID || appId === Services.appinfo.ID) {
appId = "gecko";
}
let update = {
applications: {[appId]: appEntry},
};
if (version) {
update.version = version;
}
let updateLink = getProperty(ds, targetApp, "updateLink");
if (updateLink) {
update.update_link = updateLink;
}
let updateInfoURL = getProperty(ds, targetApp, "updateInfoURL");
if (updateInfoURL) {
update.update_info_url = updateInfoURL;
}
let updateHash = getProperty(ds, targetApp, "updateHash");
if (updateHash) {
update.update_hash = updateHash;
}
updates.push(update);
}
}
}
return result;
}
var UpdateRDFConverter = {
convertToJSON(request) {
return parseRDFManifest(request);
},
};

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

@ -14,6 +14,7 @@ EXTRA_JS_MODULES.addons += [
'LightweightThemeImageOptimizer.jsm',
'ProductAddonChecker.jsm',
'SpellCheckDictionaryBootstrap.js',
'UpdateRDFConverter.jsm',
'XPIInstall.jsm',
'XPIProvider.jsm',
'XPIProviderUtils.js',

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

@ -1,30 +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>bug299716-2@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716</em:name>
<em:updateURL>http://example.com/data/test_bug299716_2.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,21 +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>bug299716-a@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test A</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,21 +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>bug299716-a@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test A</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,20 +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>bug299716-b@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test B</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,20 +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>bug299716-b@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test B</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,30 +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>bug299716-c@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test C</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,30 +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>bug299716-c@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test C</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,30 +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>bug299716-d@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test D</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,30 +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>bug299716-d@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- XPCShell -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test D</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,30 +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>bug299716-e@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<!-- XPCShell, invalid -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test E</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,30 +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>bug299716-e@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- Toolkit -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<!-- XPCShell, invalid -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test E</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,30 +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>bug299716-f@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<!-- XPCShell, invalid -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test F</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,30 +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>bug299716-f@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<!-- XPCShell, invalid -->
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test F</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,21 +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>bug299716-g@tests.mozilla.org</em:id>
<em:version>0.1</em:version>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test G</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,21 +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>bug299716-g@tests.mozilla.org</em:id>
<em:version>0.2</em:version>
<!-- Toolkit, invalid -->
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 299716 test G</em:name>
<em:updateURL>http://example.com/data/test_bug299716.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,22 +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>bug394300_1@tests.mozilla.org</em:id>
<em:version>5</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 394300 Test 1</em:name>
<em:updateURL>http://example.com/test_bug394300.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,22 +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>bug394300_2@tests.mozilla.org</em:id>
<em:version>5</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
</Description>
</em:targetApplication>
<em:name>Bug 394300 Test 2</em:name>
<em:updateURL>http://example.com/test_bug394300.rdf</em:updateURL>
</Description>
</RDF>

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

@ -1,181 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE RDF:RDF [
<!ENTITY bug299716 "urn:mozilla:extension:bug299716">
<!ENTITY addons_prefix "http://example.com/addons/test_bug299716">
<!ENTITY v0.2 "<em:version>0.2</em:version>">
<!ENTITY xpcshell.app "
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>5</em:minVersion>
<em:maxVersion>5</em:maxVersion>
">
<!ENTITY toolkit.app "
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
">
<!ENTITY invalidRange "
<em:minVersion>30</em:minVersion>
<em:maxVersion>30</em:maxVersion>
">
<!ENTITY xpcshell.invalid "
<em:id>xpcshell@tests.mozilla.org</em:id>
&invalidRange;
">
<!ENTITY toolkit.invalid "
<em:id>toolkit@mozilla.org</em:id>
&invalidRange;
">
]>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<!-- XPCShell -->
<RDF:Description about="&bug299716;-a@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-a@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-a@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_a_2.xpi">
&xpcshell.app;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- Toolkit -->
<RDF:Description about="&bug299716;-b@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-b@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-b@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_b_2.xpi">
&toolkit.app;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- XPCShell + Toolkit -->
<RDF:Description about="&bug299716;-c@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-c@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-c@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_c_2.xpi">
&xpcshell.app;
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_c_2.xpi">
&toolkit.app;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- XPCShell (Toolkit invalid) -->
<RDF:Description about="&bug299716;-d@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-d@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-d@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_d_2.xpi">
&xpcshell.app;
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_d_2.xpi">
&toolkit.invalid;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- Toolkit (XPCShell invalid), should not install -->
<RDF:Description about="&bug299716;-e@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-e@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-e@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_e_2.xpi">
&xpcshell.invalid;
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_e_2.xpi">
&toolkit.app;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- None (XPCShell, Toolkit invalid), should not install -->
<RDF:Description about="&bug299716;-f@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-f@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-f@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_f_2.xpi">
&xpcshell.invalid;
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_f_2.xpi">
&toolkit.invalid;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
<!-- Toolkit (invalid), should not install -->
<RDF:Description about="&bug299716;-g@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li RDF:resource="&bug299716;-g@tests.mozilla.org:0.2"/>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="&bug299716;-g@tests.mozilla.org:0.2">
&v0.2;
<em:targetApplication>
<RDF:Description em:updateLink="&addons_prefix;_g_2.xpi">
&toolkit.invalid;
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:RDF>

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

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:bug299716-2@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>0.1</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>2.0.*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

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

@ -1,159 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:bug394300_1@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<!-- Not a valid install - incompatible app versions -->
<RDF:li>
<RDF:Description>
<em:version>20</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>2</em:minVersion>
<em:maxVersion>2</em:maxVersion>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<!-- Valid install should be the version detected -->
<RDF:li>
<RDF:Description>
<em:version>10</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<!-- Valid install. Detecting this would indicate that the order
of entries is playing a part in the update detection. -->
<RDF:li>
<RDF:Description>
<em:version>6</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<!-- Not a valid install - no minVersion or maxVersion specified -->
<RDF:li>
<RDF:Description>
<em:version>40</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<!-- Not a valid install - incompatible app versions -->
<RDF:li>
<RDF:Description>
<em:version>30</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>2</em:minVersion>
<em:maxVersion>2</em:maxVersion>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:bug394300_2@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<!-- Not a valid install - incompatible app versions -->
<RDF:li>
<RDF:Description>
<em:version>20</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>2</em:minVersion>
<em:maxVersion>2</em:maxVersion>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<!-- Valid install should be the version detected -->
<RDF:li>
<RDF:Description>
<em:version>10</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<!-- Valid install. Detecting this would indicate that the order
of entries is playing a part in the update detection. -->
<RDF:li>
<RDF:Description>
<em:version>6</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1.9</em:minVersion>
<em:maxVersion>1.9</em:maxVersion>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<!-- Not a valid install - no minVersion or maxVersion specified -->
<RDF:li>
<RDF:Description>
<em:version>40</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<!-- Not a valid install - incompatible app versions -->
<RDF:li>
<RDF:Description>
<em:version>30</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>2</em:minVersion>
<em:maxVersion>2</em:maxVersion>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

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

@ -0,0 +1,189 @@
{
"addons": {
"addon7@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "0",
"advisory_max_version": "1"
}
},
"version": "1.0"
}
]
},
"addon12@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "http://localhost:%PORT%/addons/test_update12.xpi"
}
]
},
"addon2@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "0",
"advisory_max_version": "1"
}
},
"version": "1.0"
}
]
},
"addon4@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "0",
"advisory_max_version": "0"
}
},
"version": "5.0"
}
]
},
"addon1@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "1.0"
},
{
"applications": {
"gecko": {
"strict_min_version": "2",
"advisory_max_version": "2"
}
},
"version": "1.0"
},
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "http://localhost:%PORT%/addons/test_update.xpi",
"update_info_url": "http://example.com/updateInfo.xhtml"
}
]
},
"addon10@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "0.1",
"advisory_max_version": "0.4"
}
},
"version": "1.0",
"update_link": "http://localhost:%PORT%/addons/test_update10.xpi"
}
]
},
"addon8@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "http://localhost:%PORT%/addons/test_update8.xpi"
}
]
},
"addon11@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "0.1",
"strict_max_version": "0.2"
}
},
"version": "2.0",
"update_link": "http://localhost:%PORT%/addons/test_update11.xpi"
}
]
},
"addon9@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "http://localhost:%PORT%/addons/test_update9_2.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "0.9",
"advisory_max_version": "0.9"
}
},
"version": "3.0",
"update_link": "http://localhost:%PORT%/addons/test_update9_3.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "0.9",
"advisory_max_version": "0.9"
}
},
"version": "4.0",
"update_link": "http://localhost:%PORT%/addons/test_update9_4.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "5",
"advisory_max_version": "6"
}
},
"version": "5.0",
"update_link": "http://localhost:%PORT%/addons/test_update9_5.xpi"
}
]
},
"addon3@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "3",
"advisory_max_version": "3"
}
},
"version": "1.0"
}
]
}
}
}

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

@ -170,7 +170,7 @@
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
<em:updateLink>http://example.com/broken.xpi</em:updateLink>
<em:updateHash>sha1:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
<em:updateHash>sha256:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
@ -223,7 +223,7 @@
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
<em:updateLink>https://example.com/broken.xpi</em:updateLink>
<em:updateHash>sha1:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
<em:updateHash>sha256:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6</em:updateHash>
</RDF:Description>
</em:targetApplication>
</RDF:Description>

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

@ -0,0 +1,257 @@
{
"addons": {
"test_bug378216_9@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "http://example.com/broken.xpi",
"update_hash": "sha256:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6"
}
]
},
"test_bug378216_7@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "2"
}
},
"version": "2.0",
"update_link": "http://example.com/broken.xpi"
}
]
},
"test_bug378216_8@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "http://example.com/broken.xpi"
}
]
},
"test_bug378216_13@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "https://example.com/broken.xpi",
"update_hash": "md2:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6"
}
]
},
"compat-override@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "0.1",
"advisory_max_version": "0.2"
}
},
"version": "1.0",
"update_link": "https://example.com/addons/test1.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "0.5",
"advisory_max_version": "0.6"
}
},
"version": "2.0",
"update_link": "https://example.com/addons/test2.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "2",
"advisory_max_version": "3"
}
},
"version": "3.0",
"update_link": "https://example.com/addons/test3.xpi"
}
]
},
"compat-strict-optin@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "0.1",
"strict_max_version": "0.2"
}
},
"version": "1.0",
"update_link": "https://example.com/addons/test1.xpi"
}
]
},
"ignore-compat@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "0.1",
"advisory_max_version": "0.2"
}
},
"version": "1.0",
"update_link": "https://example.com/addons/test1.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "0.5",
"advisory_max_version": "0.6"
}
},
"version": "2.0",
"update_link": "https://example.com/addons/test2.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "2",
"advisory_max_version": "3"
}
},
"version": "3.0",
"update_link": "https://example.com/addons/test3.xpi"
}
]
},
"test_bug378216_12@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "http://example.com/broken.xpi",
"update_hash": "md2:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6"
}
]
},
"test_bug378216_10@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "https://example.com/broken.xpi"
}
]
},
"updatecheck1@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "1.0",
"update_link": "https://example.com/addons/test1.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "2",
"advisory_max_version": "2"
}
},
"version": "2.0",
"update_link": "https://example.com/addons/test2.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "3.0",
"update_link": "https://example.com/addons/test3.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "2"
}
},
"version": "2.0",
"update_link": "https://example.com/addons/test2.xpi"
},
{
"applications": {
"gecko": {
"strict_min_version": "2",
"advisory_max_version": "2"
}
},
"version": "4.0",
"update_link": "https://example.com/addons/test4.xpi"
}
]
},
"test_bug378216_5@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "http://example.com/broken.xpi"
}
]
},
"test_bug378216_15@tests.mozilla.org": {},
"test_bug378216_11@tests.mozilla.org": {
"updates": [
{
"applications": {
"gecko": {
"strict_min_version": "1",
"advisory_max_version": "1"
}
},
"version": "2.0",
"update_link": "https://example.com/broken.xpi",
"update_hash": "sha256:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6"
}
]
}
}
}

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

@ -1,204 +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/.
*/
// Disables security checking our updates which haven't been signed
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
// Update check listener.
const checkListener = {
pendingCount: 0,
onUpdateAvailable: function onUpdateAvailable(aAddon, aInstall) {
for (let currentAddon of ADDONS) {
if (currentAddon.id == aAddon.id) {
currentAddon.newInstall = aInstall;
return;
}
}
},
onUpdateFinished: function onUpdateFinished() {
if (--this.pendingCount == 0)
next_test();
}
};
// Get the HTTP server.
var testserver;
var ADDONS = [
// XPCShell
{
id: "bug299716-a@tests.mozilla.org",
addon: "test_bug299716_a_1",
installed: true,
item: null,
newInstall: null
},
// Toolkit
{
id: "bug299716-b@tests.mozilla.org",
addon: "test_bug299716_b_1",
installed: true,
item: null,
newInstall: null
},
// XPCShell + Toolkit
{
id: "bug299716-c@tests.mozilla.org",
addon: "test_bug299716_c_1",
installed: true,
item: null,
newInstall: null
},
// XPCShell (Toolkit invalid)
{
id: "bug299716-d@tests.mozilla.org",
addon: "test_bug299716_d_1",
installed: true,
item: null,
newInstall: null
},
// Toolkit (XPCShell invalid)
{
id: "bug299716-e@tests.mozilla.org",
addon: "test_bug299716_e_1",
installed: false,
item: null,
newInstall: null,
failedAppName: "XPCShell"
},
// None (XPCShell, Toolkit invalid)
{
id: "bug299716-f@tests.mozilla.org",
addon: "test_bug299716_f_1",
installed: false,
item: null,
newInstall: null,
failedAppName: "XPCShell"
},
// None (Toolkit invalid)
{
id: "bug299716-g@tests.mozilla.org",
addon: "test_bug299716_g_1",
installed: false,
item: null,
newInstall: null,
failedAppName: "Toolkit"
},
];
var next_test = function() {};
function do_check_item(aItem, aVersion, aAddonsEntry) {
if (aAddonsEntry.installed) {
if (aItem == null)
do_throw("Addon " + aAddonsEntry.id + " wasn't detected");
if (aItem.version != aVersion)
do_throw("Addon " + aAddonsEntry.id + " was version " + aItem.version + " instead of " + aVersion);
} else if (aItem != null) {
do_throw("Addon " + aAddonsEntry.id + " was detected");
}
}
/**
* Start the test by installing extensions.
*/
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "5", "1.9");
const dataDir = do_get_file("data");
const addonsDir = do_get_addon(ADDONS[0].addon).parent;
// Make sure we can actually get our data files.
const xpiFile = addonsDir.clone();
xpiFile.append("test_bug299716_a_2.xpi");
Assert.ok(xpiFile.exists());
// Create and configure the HTTP server.
testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
testserver.registerDirectory("/addons/", addonsDir);
testserver.registerDirectory("/data/", dataDir);
// Make sure we can fetch the files over HTTP.
const xhr = new XMLHttpRequest();
xhr.open("GET", "http://example.com/addons/test_bug299716_a_2.xpi", false);
xhr.send(null);
Assert.ok(xhr.status == 200);
xhr.open("GET", "http://example.com/data/test_bug299716.rdf", false);
xhr.send(null);
Assert.ok(xhr.status == 200);
// Start the real test.
startupManager();
dump("\n\n*** INSTALLING NEW ITEMS\n\n");
installAllFiles(ADDONS.map(a => do_get_addon(a.addon)), run_test_pt2,
true);
}
/**
* Check the versions of all items, and ask the extension manager to find updates.
*/
function run_test_pt2() {
dump("\n\n*** DONE INSTALLING NEW ITEMS\n\n");
dump("\n\n*** RESTARTING EXTENSION MANAGER\n\n");
restartManager();
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(items) {
dump("\n\n*** REQUESTING UPDATE\n\n");
// checkListener will call run_test_pt3().
next_test = run_test_pt3;
// Try to update the items.
for (var i = 0; i < ADDONS.length; i++) {
var item = items[i];
do_check_item(item, "0.1", ADDONS[i]);
if (item) {
checkListener.pendingCount++;
ADDONS[i].item = item;
item.findUpdates(checkListener, AddonManager.UPDATE_WHEN_USER_REQUESTED);
}
}
});
}
/**
* Install new items for each enabled extension.
*/
function run_test_pt3() {
// Install the new items.
dump("\n\n*** UPDATING ITEMS\n\n");
completeAllInstalls(ADDONS.filter(a => a.newInstall).map(a => a.newInstall),
run_test_pt4);
}
/**
* Check the final version of each extension.
*/
function run_test_pt4() {
dump("\n\n*** RESTARTING EXTENSION MANAGER\n\n");
restartManager();
dump("\n\n*** FINAL CHECKS\n\n");
AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(items) {
for (var i = 0; i < ADDONS.length; i++) {
var item = items[i];
do_check_item(item, "0.2", ADDONS[i]);
}
do_test_finished();
});
}

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

@ -1,46 +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/.
*/
// Disables security checking our updates which haven't been signed
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
var testserver;
var ADDON = {
id: "bug299716-2@tests.mozilla.org",
addon: "test_bug299716_2"
};
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "1.9");
const dataDir = do_get_file("data");
const addonsDir = do_get_addon(ADDON.addon).parent;
// Create and configure the HTTP server.
testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
testserver.registerDirectory("/addons/", addonsDir);
testserver.registerDirectory("/data/", dataDir);
startupManager();
installAllFiles([do_get_addon(ADDON.addon)], function() {
restartManager();
AddonManager.getAddonByID(ADDON.id, function(item) {
Assert.equal(item.version, 0.1);
Assert.ok(!item.isCompatible);
item.findUpdates({
onUpdateFinished(addon) {
Assert.ok(!item.isCompatible);
do_test_finished();
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
});
}

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

@ -32,6 +32,10 @@ function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
startupManager();
server = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
server.registerDirectory("/", do_get_file("data"));
installAllFiles([do_get_addon("test_bug394300_1"),
do_get_addon("test_bug394300_2")], function() {
@ -43,9 +47,6 @@ function run_test() {
Assert.notEqual(updates[0], null);
Assert.notEqual(updates[1], null);
server = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
server.registerDirectory("/", do_get_file("data"));
updates[0].findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED);
updates[1].findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});

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

@ -41,7 +41,7 @@ mapFile("/data/test_delay_updates_defer.json", testserver);
mapFile("/data/test_no_update.json", testserver);
testserver.registerDirectory("/addons/", do_get_file("addons"));
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "42", "42");
// add-on registers upgrade listener, and ignores update.
add_task(async function delay_updates_ignore() {

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

@ -88,7 +88,7 @@ add_task(async function test_default_values() {
equal(updates.length, 1);
let update = updates[0];
equal(update.targetApplications.length, 1);
equal(update.targetApplications.length, 2);
let targetApp = update.targetApplications[0];
equal(targetApp.id, TOOLKIT_ID);
@ -149,7 +149,7 @@ add_task(async function test_explicit_values() {
equal(updates.length, 1);
let update = updates[0];
equal(update.targetApplications.length, 1);
equal(update.targetApplications.length, 2);
let targetApp = update.targetApplications[0];
equal(targetApp.id, TOOLKIT_ID);

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

@ -0,0 +1,77 @@
"use strict";
// Tests the update RDF to JSON converter.
ChromeUtils.import("resource://gre/modules/addons/AddonUpdateChecker.jsm");
ChromeUtils.import("resource://gre/modules/addons/UpdateRDFConverter.jsm");
var testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
testserver.registerDirectory("/data/", do_get_file("data"));
const BASE_URL = "http://example.com/data";
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
function checkUpdates(aId, aUpdateFile) {
return new Promise((resolve, reject) => {
AddonUpdateChecker.checkForUpdates(aId, `${BASE_URL}/${aUpdateFile}`, {
onUpdateCheckComplete: resolve,
onUpdateCheckError(status) {
let error = new Error("Update check failed with status " + status);
error.status = status;
reject(error);
}
});
});
}
function makeRequest(url) {
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.addEventListener("load", () => resolve(xhr), {once: true});
xhr.addEventListener("error", reject, {once: true});
xhr.send();
});
}
add_task(async function test_update_rdf_to_json() {
for (let base of ["test_update", "test_updatecheck"]) {
info(`Testing ${base}.rdf`);
let rdfRequest = await makeRequest(`${BASE_URL}/${base}.rdf`);
let jsonRequest = await makeRequest(`${BASE_URL}/${base}_rdf.json`);
let rdfJSON = UpdateRDFConverter.convertToJSON(rdfRequest);
let json = JSON.parse(jsonRequest.responseText);
deepEqual(Object.keys(rdfJSON).sort(), Object.keys(json).sort(),
"Should have the same keys");
deepEqual(Object.keys(rdfJSON.addons).sort(), Object.keys(json.addons).sort(),
"Should have the same add-on IDs");
for (let addon of Object.keys(json.addons)) {
deepEqual(rdfJSON.addons[addon], json.addons[addon],
`Should have the same entry for add-on ${addon}`);
}
}
});
add_task(async function test_update_check() {
for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
let updates = await checkUpdates("updatecheck1@tests.mozilla.org", file);
equal(updates.length, 5);
let update = AddonUpdateChecker.getNewestCompatibleUpdate(updates);
notEqual(update, null);
equal(update.version, "3.0");
update = AddonUpdateChecker.getCompatibilityUpdate(updates, "2");
notEqual(update, null);
equal(update.version, "2.0");
equal(update.targetApplications[0].minVersion, "1");
equal(update.targetApplications[0].maxVersion, "2");
}
});

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

@ -169,7 +169,7 @@ add_task(async function() {
});
add_task(async function() {
for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
for (let file of ["test_updatecheck.json"]) {
try {
await checkUpdates("test_bug378216_15@tests.mozilla.org",
file);

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

@ -36,7 +36,7 @@ testserver.registerDirectory("/data/", do_get_file("data"));
testserver.registerDirectory("/addons/", do_get_file("addons"));
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
startupManager();
run_next_test();
}

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

@ -93,12 +93,6 @@ tags = blocklist
[test_bootstrap.js]
skip-if = true # Bug 1358846 Bug 1365021 Bug 676992
[test_bootstrap_const.js]
[test_bug299716.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_bug299716_2.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_bug324121.js]
# Bug 676992: test consistently hangs on Android
# Bug 1026805: frequent hangs on OSX 10.8
@ -117,10 +111,6 @@ skip-if = os == "android"
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
tags = blocklist
[test_bug394300.js]
# Bug 676992: test consistently hangs on Android
# Bug 1026805: frequent hangs on OSX 10.8
skip-if = os == "android" || os == "mac"
[test_bug397778.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
@ -322,6 +312,7 @@ skip-if = os == "win" # Bug 1358846
[test_update.js]
# Bug 676992: test consistently hangs on Android; bug 1330227 - linux
skip-if = os == "android" || os == "linux"
[test_update_rdf.js]
[test_update_webextensions.js]
tags = webextensions
[test_updateCancel.js]