зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1257565 - add remote settings support for plugin and addon blocklist, r=aswan
MozReview-Commit-ID: AiGycyhGUta Differential Revision: https://phabricator.services.mozilla.com/D29834 --HG-- rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_appversion.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_appversion.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_metadata_filters.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_metadata_filters.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_osabi.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_osabi.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_plugin_flashonly.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_plugin_flashonly.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_plugin_outdated.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_plugin_outdated.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_plugin_regexp.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_plugin_regexp.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_plugin_severities.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_plugin_severities.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_prefs.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_prefs.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklist_severities.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_severities.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_blocklistchange.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklistchange.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_pluginBlocklistCtp.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_pluginBlocklistCtp.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_pluginInfoURL.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_pluginInfoURL.js rename : toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/test_softblocked.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_softblocked.js extra : moz-landing-system : lando
This commit is contained in:
Родитель
d8a027e065
Коммит
d773fd23da
|
@ -192,36 +192,19 @@ function clearAllPluginPermissions() {
|
|||
}
|
||||
}
|
||||
|
||||
function updateBlocklist(aCallback) {
|
||||
let blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
|
||||
.getService(Ci.nsITimerCallback);
|
||||
let observer = function() {
|
||||
Services.obs.removeObserver(observer, "blocklist-updated");
|
||||
SimpleTest.executeSoon(aCallback);
|
||||
};
|
||||
Services.obs.addObserver(observer, "blocklist-updated");
|
||||
blocklistNotifier.notify(null);
|
||||
}
|
||||
|
||||
var _originalTestBlocklistURL = null;
|
||||
function setAndUpdateBlocklist(aURL, aCallback) {
|
||||
if (!_originalTestBlocklistURL) {
|
||||
_originalTestBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url");
|
||||
}
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", aURL);
|
||||
updateBlocklist(aCallback);
|
||||
}
|
||||
|
||||
// A generator that insures a new blocklist is loaded (in both
|
||||
// An async helper that insures a new blocklist is loaded (in both
|
||||
// processes if applicable).
|
||||
var _originalTestBlocklistURL = null;
|
||||
async function asyncSetAndUpdateBlocklist(aURL, aBrowser) {
|
||||
// FIXME: this needs to also work with the remote settings blocklist,
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1549548
|
||||
info("*** loading new blocklist: " + aURL);
|
||||
let doTestRemote = aBrowser ? aBrowser.isRemoteBrowser : false;
|
||||
if (!_originalTestBlocklistURL) {
|
||||
_originalTestBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url");
|
||||
}
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", aURL);
|
||||
let localPromise = TestUtils.topicObserved("blocklist-updated");
|
||||
let localPromise = TestUtils.topicObserved("plugin-blocklist-updated");
|
||||
let blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
|
||||
.getService(Ci.nsITimerCallback);
|
||||
blocklistNotifier.notify(null);
|
||||
|
|
|
@ -268,8 +268,8 @@ class BlocklistPromiseHandler final
|
|||
sPendingBlocklistStateRequests--;
|
||||
// If this was the only remaining pending request, check if we need to write
|
||||
// state and if so update the child processes.
|
||||
if (!sPendingBlocklistStateRequests &&
|
||||
sPluginBlocklistStatesChangedSinceLastWrite) {
|
||||
if (!sPendingBlocklistStateRequests) {
|
||||
if (sPluginBlocklistStatesChangedSinceLastWrite) {
|
||||
sPluginBlocklistStatesChangedSinceLastWrite = false;
|
||||
|
||||
RefPtr<nsPluginHost> host = nsPluginHost::GetInst();
|
||||
|
@ -281,6 +281,15 @@ class BlocklistPromiseHandler final
|
|||
host->IncrementChromeEpoch();
|
||||
host->SendPluginsToContent();
|
||||
}
|
||||
|
||||
// Now notify observers that we're done updating plugin state.
|
||||
nsCOMPtr<nsIObserverService> obsService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (obsService) {
|
||||
obsService->NotifyObservers(
|
||||
nullptr, "plugin-blocklist-updates-finished", nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
|
@ -358,7 +367,7 @@ nsPluginHost::nsPluginHost()
|
|||
if (obsService) {
|
||||
obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
if (XRE_IsParentProcess()) {
|
||||
obsService->AddObserver(this, "blocklist-updated", false);
|
||||
obsService->AddObserver(this, "plugin-blocklist-updated", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3305,7 +3314,7 @@ NS_IMETHODIMP nsPluginHost::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
LoadPlugins();
|
||||
}
|
||||
}
|
||||
if (XRE_IsParentProcess() && !strcmp("blocklist-updated", aTopic)) {
|
||||
if (XRE_IsParentProcess() && !strcmp("plugin-blocklist-updated", aTopic)) {
|
||||
// The blocklist has updated. Asynchronously get blocklist state for all
|
||||
// items. The promise resolution handler takes care of checking if anything
|
||||
// changed, and writing an updated state to file, as well as sending data to
|
||||
|
|
|
@ -20,13 +20,6 @@ const PREF_SECURITY_SETTINGS_ONECRL_COLLECTION = "services.settings.security.one
|
|||
const PREF_SECURITY_SETTINGS_ONECRL_SIGNER = "services.settings.security.onecrl.signer";
|
||||
const PREF_SECURITY_SETTINGS_ONECRL_CHECKED = "services.settings.security.onecrl.checked";
|
||||
|
||||
const PREF_BLOCKLIST_BUCKET = "services.blocklist.bucket";
|
||||
const PREF_BLOCKLIST_ADDONS_COLLECTION = "services.blocklist.addons.collection";
|
||||
const PREF_BLOCKLIST_ADDONS_CHECKED_SECONDS = "services.blocklist.addons.checked";
|
||||
const PREF_BLOCKLIST_ADDONS_SIGNER = "services.blocklist.addons.signer";
|
||||
const PREF_BLOCKLIST_PLUGINS_COLLECTION = "services.blocklist.plugins.collection";
|
||||
const PREF_BLOCKLIST_PLUGINS_CHECKED_SECONDS = "services.blocklist.plugins.checked";
|
||||
const PREF_BLOCKLIST_PLUGINS_SIGNER = "services.blocklist.plugins.signer";
|
||||
const PREF_BLOCKLIST_PINNING_ENABLED = "services.blocklist.pinning.enabled";
|
||||
const PREF_BLOCKLIST_PINNING_BUCKET = "services.blocklist.pinning.bucket";
|
||||
const PREF_BLOCKLIST_PINNING_COLLECTION = "services.blocklist.pinning.collection";
|
||||
|
@ -193,6 +186,8 @@ async function updatePinningList({ data: { current: records } }) {
|
|||
* This custom filter function is used to limit the entries returned
|
||||
* by `RemoteSettings("...").get()` depending on the target app information
|
||||
* defined on entries.
|
||||
*
|
||||
* Note that this is async because `jexlFilterFunc` is async.
|
||||
*/
|
||||
async function targetAppFilter(entry, environment) {
|
||||
// If the entry has a JEXL filter expression, it should prevail.
|
||||
|
@ -252,10 +247,8 @@ async function targetAppFilter(entry, environment) {
|
|||
return null;
|
||||
}
|
||||
|
||||
var AddonBlocklistClient;
|
||||
var OneCRLBlocklistClient;
|
||||
var PinningBlocklistClient;
|
||||
var PluginBlocklistClient;
|
||||
var RemoteSecuritySettingsClient;
|
||||
|
||||
function initialize() {
|
||||
|
@ -266,20 +259,6 @@ function initialize() {
|
|||
});
|
||||
OneCRLBlocklistClient.on("sync", updateCertBlocklist);
|
||||
|
||||
AddonBlocklistClient = RemoteSettings(Services.prefs.getCharPref(PREF_BLOCKLIST_ADDONS_COLLECTION), {
|
||||
bucketNamePref: PREF_BLOCKLIST_BUCKET,
|
||||
lastCheckTimePref: PREF_BLOCKLIST_ADDONS_CHECKED_SECONDS,
|
||||
signerName: Services.prefs.getCharPref(PREF_BLOCKLIST_ADDONS_SIGNER),
|
||||
filterFunc: targetAppFilter,
|
||||
});
|
||||
|
||||
PluginBlocklistClient = RemoteSettings(Services.prefs.getCharPref(PREF_BLOCKLIST_PLUGINS_COLLECTION), {
|
||||
bucketNamePref: PREF_BLOCKLIST_BUCKET,
|
||||
lastCheckTimePref: PREF_BLOCKLIST_PLUGINS_CHECKED_SECONDS,
|
||||
signerName: Services.prefs.getCharPref(PREF_BLOCKLIST_PLUGINS_SIGNER),
|
||||
filterFunc: targetAppFilter,
|
||||
});
|
||||
|
||||
PinningBlocklistClient = RemoteSettings(Services.prefs.getCharPref(PREF_BLOCKLIST_PINNING_COLLECTION), {
|
||||
bucketNamePref: PREF_BLOCKLIST_PINNING_BUCKET,
|
||||
lastCheckTimePref: PREF_BLOCKLIST_PINNING_CHECKED_SECONDS,
|
||||
|
@ -296,8 +275,6 @@ function initialize() {
|
|||
|
||||
return {
|
||||
OneCRLBlocklistClient,
|
||||
AddonBlocklistClient,
|
||||
PluginBlocklistClient,
|
||||
PinningBlocklistClient,
|
||||
RemoteSecuritySettingsClient,
|
||||
};
|
||||
|
@ -305,8 +282,6 @@ function initialize() {
|
|||
|
||||
return {
|
||||
OneCRLBlocklistClient,
|
||||
AddonBlocklistClient,
|
||||
PluginBlocklistClient,
|
||||
PinningBlocklistClient,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ const SEARCH_ENGINE_MODIFIED_TOPIC = "browser-search-engine-modified";
|
|||
const SEARCH_SERVICE_TOPIC = "browser-search-service";
|
||||
const SESSIONSTORE_WINDOWS_RESTORED_TOPIC = "sessionstore-windows-restored";
|
||||
const PREF_CHANGED_TOPIC = "nsPref:changed";
|
||||
const BLOCKLIST_LOADED_TOPIC = "blocklist-loaded";
|
||||
const BLOCKLIST_LOADED_TOPIC = "plugin-blocklist-loaded";
|
||||
const AUTO_UPDATE_PREF_CHANGE_TOPIC = "auto-update-config-change";
|
||||
|
||||
/**
|
||||
|
|
|
@ -128,6 +128,152 @@ const PREF_BLOCKLIST_BUCKET = "services.blocklist.bucket";
|
|||
const PREF_BLOCKLIST_GFX_COLLECTION = "services.blocklist.gfx.collection";
|
||||
const PREF_BLOCKLIST_GFX_CHECKED_SECONDS = "services.blocklist.gfx.checked";
|
||||
const PREF_BLOCKLIST_GFX_SIGNER = "services.blocklist.gfx.signer";
|
||||
const PREF_BLOCKLIST_PLUGINS_COLLECTION = "services.blocklist.plugins.collection";
|
||||
const PREF_BLOCKLIST_PLUGINS_CHECKED_SECONDS = "services.blocklist.plugins.checked";
|
||||
const PREF_BLOCKLIST_PLUGINS_SIGNER = "services.blocklist.plugins.signer";
|
||||
const PREF_BLOCKLIST_ADDONS_COLLECTION = "services.blocklist.addons.collection";
|
||||
const PREF_BLOCKLIST_ADDONS_CHECKED_SECONDS = "services.blocklist.addons.checked";
|
||||
const PREF_BLOCKLIST_ADDONS_SIGNER = "services.blocklist.addons.signer";
|
||||
|
||||
const Utils = {
|
||||
/**
|
||||
* Checks whether this entry is valid for the current OS and ABI.
|
||||
* If the entry has an "os" property then the current OS must appear in
|
||||
* its comma separated list for it to be valid. Similarly for the
|
||||
* xpcomabi property.
|
||||
*
|
||||
* @param {Object} item
|
||||
* The blocklist item.
|
||||
* @returns {bool}
|
||||
* Whether the entry matches the current OS.
|
||||
*/
|
||||
matchesOSABI(item) {
|
||||
if (item.os) {
|
||||
let os = item.os.split(",");
|
||||
if (!os.includes(gAppOS)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.xpcomabi) {
|
||||
let xpcomabi = item.xpcomabi.split(",");
|
||||
if (!xpcomabi.includes(gApp.XPCOMABI)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if a version is higher than or equal to the minVersion (if provided)
|
||||
* and lower than or equal to the maxVersion (if provided).
|
||||
* @param {string} version
|
||||
* The version to test.
|
||||
* @param {string?} minVersion
|
||||
* The minimum version. If null it is assumed that version is always
|
||||
* larger.
|
||||
* @param {string?} maxVersion
|
||||
* The maximum version. If null it is assumed that version is always
|
||||
* smaller.
|
||||
* @returns {boolean}
|
||||
* Whether the item matches the range.
|
||||
*/
|
||||
versionInRange(version, minVersion, maxVersion) {
|
||||
if (minVersion && Services.vc.compare(version, minVersion) < 0)
|
||||
return false;
|
||||
if (maxVersion && Services.vc.compare(version, maxVersion) > 0)
|
||||
return false;
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Tests if this versionRange matches the item specified, and has a matching
|
||||
* targetApplication id and version.
|
||||
* @param {Object} versionRange
|
||||
* The versionRange to check against
|
||||
* @param {string} itemVersion
|
||||
* The version of the actual addon/plugin to test for.
|
||||
* @param {string} appVersion
|
||||
* The version of the application to test for.
|
||||
* @param {string} toolkitVersion
|
||||
* The version of toolkit to check for.
|
||||
* @returns {boolean}
|
||||
* True if this version range covers the item and app/toolkit version given.
|
||||
*/
|
||||
versionsMatch(versionRange, itemVersion, appVersion, toolkitVersion) {
|
||||
// Some platforms have no version for plugins, these don't match if there
|
||||
// was a min/maxVersion provided
|
||||
if (!itemVersion && (versionRange.minVersion || versionRange.maxVersion))
|
||||
return false;
|
||||
|
||||
// Check if the item version matches
|
||||
if (!this.versionInRange(itemVersion, versionRange.minVersion, versionRange.maxVersion))
|
||||
return false;
|
||||
|
||||
// Check if the application or toolkit version matches
|
||||
for (let tA of versionRange.targetApplication) {
|
||||
if (tA.guid == gAppID && this.versionInRange(appVersion, tA.minVersion, tA.maxVersion)) {
|
||||
return true;
|
||||
}
|
||||
if (tA.guid == TOOLKIT_ID &&
|
||||
this.versionInRange(toolkitVersion, tA.minVersion, tA.maxVersion)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a blocklist JS object entry, ensure it has a versionRange property, where
|
||||
* each versionRange property has valid severity and vulnerabilityStatus properties,
|
||||
* and at least 1 valid targetApplication.
|
||||
* If it didn't have a valid targetApplication array before and/or it was empty,
|
||||
* fill it with an entry with null min/maxVersion properties, which will match
|
||||
* every version.
|
||||
*
|
||||
* If there *are* targetApplications, if any of them don't have a guid property,
|
||||
* assign them the current app's guid.
|
||||
*
|
||||
* @param {Object} entry
|
||||
* blocklist entry object.
|
||||
*/
|
||||
ensureVersionRangeIsSane(entry) {
|
||||
if (!entry.versionRange.length) {
|
||||
entry.versionRange.push({});
|
||||
}
|
||||
for (let vr of entry.versionRange) {
|
||||
if (!vr.hasOwnProperty("severity")) {
|
||||
vr.severity = DEFAULT_SEVERITY;
|
||||
}
|
||||
if (!vr.hasOwnProperty("vulnerabilityStatus")) {
|
||||
vr.vulnerabilityStatus = VULNERABILITYSTATUS_NONE;
|
||||
}
|
||||
|
||||
if (!Array.isArray(vr.targetApplication)) {
|
||||
vr.targetApplication = [];
|
||||
}
|
||||
if (!vr.targetApplication.length) {
|
||||
vr.targetApplication.push({minVersion: null, maxVersion: null});
|
||||
}
|
||||
vr.targetApplication.forEach(tA => {
|
||||
if (!tA.guid) {
|
||||
tA.guid = gAppID;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a blocklist URL for the given blockID
|
||||
* @param {String} id the blockID to use
|
||||
* @returns {String} the blocklist URL.
|
||||
*/
|
||||
_createBlocklistURL(id) {
|
||||
let url = Services.urlFormatter.formatURLPref(PREF_BLOCKLIST_ITEM_URL);
|
||||
return url.replace(/%blockID%/g, id);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* The Graphics blocklist implementation. The JSON objects for graphics blocks look
|
||||
|
@ -256,6 +402,612 @@ this.GfxBlocklistRS = {
|
|||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The plugins blocklist implementation. The JSON objects for plugin blocks look
|
||||
* something like:
|
||||
*
|
||||
* {
|
||||
* "blockID":"p906",
|
||||
* "details": {
|
||||
* "bug":"https://bugzilla.mozilla.org/show_bug.cgi?id=1159917",
|
||||
* "who":"Which users it affects",
|
||||
* "why":"Why it's being blocklisted",
|
||||
* "name":"Java Plugin 7 update 45 to 78 (click-to-play), Windows",
|
||||
* "created":"2015-05-19T09:02:45Z"
|
||||
* },
|
||||
* "enabled":true,
|
||||
* "infoURL":"https://java.com/",
|
||||
* "matchName":"Java\\(TM\\) Platform SE 7 U(4[5-9]|(5|6)\\d|7[0-8])(\\s[^\\d\\._U]|$)",
|
||||
* "versionRange":[
|
||||
* {
|
||||
* "severity":0,
|
||||
* "targetApplication":[
|
||||
* {
|
||||
* "guid":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
|
||||
* "maxVersion":"57.0.*",
|
||||
* "minVersion":"0"
|
||||
* }
|
||||
* ],
|
||||
* "vulnerabilityStatus":1
|
||||
* }
|
||||
* ],
|
||||
* "matchFilename":"npjp2\\.dll",
|
||||
* "id":"f254e5bc-12c7-7954-fe6b-8f1fdab0ae88",
|
||||
* "last_modified":1519390914542,
|
||||
* }
|
||||
*
|
||||
* Note: we assign to the global to allow tests to reach the object directly.
|
||||
*/
|
||||
this.PluginBlocklistRS = {
|
||||
_matchProps: {
|
||||
"matchDescription": "description",
|
||||
"matchFilename": "filename",
|
||||
"matchName": "name",
|
||||
},
|
||||
|
||||
async _ensureEntries() {
|
||||
await this._ensureInitialized();
|
||||
if (!this._entries && gBlocklistEnabled) {
|
||||
await this._updateEntries();
|
||||
|
||||
// Dispatch to mainthread because consumers may try to construct nsIPluginHost
|
||||
// again based on this notification, while we were called from nsIPluginHost
|
||||
// anyway, leading to re-entrancy.
|
||||
Services.tm.dispatchToMainThread(function() {
|
||||
Services.obs.notifyObservers(null, "plugin-blocklist-loaded");
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async _updateEntries() {
|
||||
if (!gBlocklistEnabled) {
|
||||
this._entries = [];
|
||||
return;
|
||||
}
|
||||
this._entries = await this._client.get().catch(ex => Cu.reportError(ex));
|
||||
// Handle error silently. This can happen if our request to fetch data is aborted,
|
||||
// e.g. by application shutdown.
|
||||
if (!this._entries) {
|
||||
this._entries = [];
|
||||
return;
|
||||
}
|
||||
this._entries.forEach(entry => {
|
||||
entry.matches = {};
|
||||
for (let k of Object.keys(this._matchProps)) {
|
||||
if (entry[k]) {
|
||||
try {
|
||||
entry.matches[this._matchProps[k]] = new RegExp(entry[k], "m");
|
||||
} catch (ex) { /* Ignore invalid regexes */ }
|
||||
}
|
||||
}
|
||||
Utils.ensureVersionRangeIsSane(entry);
|
||||
});
|
||||
},
|
||||
|
||||
async _filterItem(entry) {
|
||||
if (!(await BlocklistClients.targetAppFilter(entry, {appID: gAppID, version: gApp.version}))) {
|
||||
return null;
|
||||
}
|
||||
if (!Utils.matchesOSABI(entry)) {
|
||||
return null;
|
||||
}
|
||||
if (!entry.matchFilename && !entry.matchName && !entry.matchDescription) {
|
||||
Cu.reportError(new Error("Nothing to filter plugin item " + entry.blockID + " on"));
|
||||
return null;
|
||||
}
|
||||
return entry;
|
||||
},
|
||||
|
||||
async _ensureInitialized() {
|
||||
if (!gBlocklistEnabled || this._initialized) {
|
||||
return;
|
||||
}
|
||||
this._initialized = true;
|
||||
this._client = RemoteSettings(Services.prefs.getCharPref(PREF_BLOCKLIST_PLUGINS_COLLECTION), {
|
||||
bucketNamePref: PREF_BLOCKLIST_BUCKET,
|
||||
lastCheckTimePref: PREF_BLOCKLIST_PLUGINS_CHECKED_SECONDS,
|
||||
signerName: Services.prefs.getCharPref(PREF_BLOCKLIST_PLUGINS_SIGNER),
|
||||
filterFunc: this._filterItem,
|
||||
});
|
||||
this._onUpdate = this._onUpdate.bind(this);
|
||||
this._client.on("sync", this._onUpdate);
|
||||
},
|
||||
|
||||
shutdown() {
|
||||
if (this._client) {
|
||||
this._client.off("sync", this._onUpdate);
|
||||
}
|
||||
},
|
||||
|
||||
async _onUpdate() {
|
||||
let oldEntries = this._entries || [];
|
||||
await this._ensureInitialized();
|
||||
await this._updateEntries();
|
||||
const pluginHost = Cc["@mozilla.org/plugin/host;1"].
|
||||
getService(Ci.nsIPluginHost);
|
||||
const plugins = pluginHost.getPluginTags();
|
||||
|
||||
let blockedItems = [];
|
||||
|
||||
for (let plugin of plugins) {
|
||||
let oldState = this._getState(plugin, oldEntries);
|
||||
let state = this._getState(plugin, this._entries);
|
||||
LOG("Blocklist state for " + plugin.name + " changed from " +
|
||||
oldState + " to " + state);
|
||||
// We don't want to re-warn about items
|
||||
if (state == oldState)
|
||||
continue;
|
||||
|
||||
if (oldState == Ci.nsIBlocklistService.STATE_BLOCKED) {
|
||||
if (state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
|
||||
plugin.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
|
||||
} else if (!plugin.disabled && state != Ci.nsIBlocklistService.STATE_NOT_BLOCKED) {
|
||||
if (state != Ci.nsIBlocklistService.STATE_OUTDATED &&
|
||||
state != Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE &&
|
||||
state != Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE) {
|
||||
blockedItems.push({
|
||||
name: plugin.name,
|
||||
version: plugin.version,
|
||||
icon: "chrome://mozapps/skin/plugins/pluginGeneric.svg",
|
||||
disable: false,
|
||||
blocked: state == Ci.nsIBlocklistService.STATE_BLOCKED,
|
||||
item: plugin,
|
||||
url: await this.getURL(plugin),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (blockedItems.length) {
|
||||
this._showBlockedPluginsPrompt(blockedItems);
|
||||
} else {
|
||||
this._notifyUpdate();
|
||||
}
|
||||
},
|
||||
|
||||
_showBlockedPluginsPrompt(blockedPlugins) {
|
||||
if ("@mozilla.org/addons/blocklist-prompt;1" in Cc) {
|
||||
try {
|
||||
let blockedPrompter = Cc["@mozilla.org/addons/blocklist-prompt;1"]
|
||||
.getService().wrappedJSObject;
|
||||
blockedPrompter.prompt(blockedPlugins);
|
||||
} catch (e) {
|
||||
LOG(e);
|
||||
}
|
||||
this._notifyUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
let args = {
|
||||
restart: false,
|
||||
list: blockedPlugins,
|
||||
};
|
||||
// This lets the dialog get the raw js object
|
||||
args.wrappedJSObject = args;
|
||||
|
||||
/*
|
||||
Some tests run without UI, so the async code listens to a message
|
||||
that can be sent programatically
|
||||
*/
|
||||
let applyBlocklistChanges = async () => {
|
||||
Services.obs.removeObserver(applyBlocklistChanges, "addon-blocklist-closed");
|
||||
|
||||
for (let blockedData of blockedPlugins) {
|
||||
if (!blockedData.disable)
|
||||
continue;
|
||||
|
||||
// This will disable all the plugins immediately.
|
||||
if (blockedData.item instanceof Ci.nsIPluginTag) {
|
||||
blockedData.item.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
if (!args.restart) {
|
||||
this._notifyUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to ensure the new blocklist state is written to disk before restarting.
|
||||
// We'll notify about the blocklist update, then wait for nsIPluginHost
|
||||
// to finish processing it, then restart the browser.
|
||||
let pluginUpdatesFinishedPromise = new Promise(resolve => {
|
||||
Services.obs.addObserver(function updatesFinished() {
|
||||
Services.obs.removeObserver(updatesFinished, "plugin-blocklist-updates-finished");
|
||||
resolve();
|
||||
}, "plugin-blocklist-updates-finished");
|
||||
});
|
||||
this._notifyUpdate();
|
||||
await pluginUpdatesFinishedPromise;
|
||||
|
||||
// Notify all windows that an application quit has been requested.
|
||||
var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].
|
||||
createInstance(Ci.nsISupportsPRBool);
|
||||
Services.obs.notifyObservers(cancelQuit, "quit-application-requested");
|
||||
|
||||
// Something aborted the quit process.
|
||||
if (cancelQuit.data)
|
||||
return;
|
||||
|
||||
Services.startup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
|
||||
};
|
||||
|
||||
Services.obs.addObserver(applyBlocklistChanges, "addon-blocklist-closed");
|
||||
|
||||
if (Services.prefs.getBoolPref(PREF_BLOCKLIST_SUPPRESSUI, false)) {
|
||||
applyBlocklistChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
function blocklistUnloadHandler(event) {
|
||||
if (event.target.location == URI_BLOCKLIST_DIALOG) {
|
||||
applyBlocklistChanges();
|
||||
blocklistWindow.removeEventListener("unload", blocklistUnloadHandler);
|
||||
}
|
||||
}
|
||||
|
||||
let blocklistWindow = Services.ww.openWindow(null, URI_BLOCKLIST_DIALOG, "",
|
||||
"chrome,centerscreen,dialog,titlebar", args);
|
||||
if (blocklistWindow)
|
||||
blocklistWindow.addEventListener("unload", blocklistUnloadHandler);
|
||||
},
|
||||
|
||||
_notifyUpdate() {
|
||||
Services.obs.notifyObservers(null, "plugin-blocklist-updated");
|
||||
},
|
||||
|
||||
async getURL(plugin) {
|
||||
await this._ensureEntries();
|
||||
let r = this._getEntry(plugin, this._entries);
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
let blockEntry = r.entry;
|
||||
if (!blockEntry.blockID) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return blockEntry.infoURL || Utils._createBlocklistURL(blockEntry.blockID);
|
||||
},
|
||||
|
||||
async getState(plugin, appVersion, toolkitVersion) {
|
||||
if (AppConstants.platform == "android") {
|
||||
return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
|
||||
}
|
||||
await this._ensureEntries();
|
||||
return this._getState(plugin, this._entries, appVersion, toolkitVersion);
|
||||
},
|
||||
|
||||
/**
|
||||
* Private helper to get the blocklist entry for a plugin given a set of
|
||||
* blocklist entries and versions.
|
||||
*
|
||||
* @param {nsIPluginTag} plugin
|
||||
* The nsIPluginTag to get the blocklist state for.
|
||||
* @param {object[]} pluginEntries
|
||||
* The plugin blocklist entries to compare against.
|
||||
* @param {string?} appVersion
|
||||
* The application version to compare to, will use the current
|
||||
* version if null.
|
||||
* @param {string?} toolkitVersion
|
||||
* The toolkit version to compare to, will use the current version if
|
||||
* null.
|
||||
* @returns {object?}
|
||||
* {entry: blocklistEntry, version: blocklistEntryVersion},
|
||||
* or null if there is no matching entry.
|
||||
*/
|
||||
_getEntry(plugin, pluginEntries, appVersion, toolkitVersion) {
|
||||
if (!gBlocklistEnabled)
|
||||
return null;
|
||||
|
||||
// Not all applications implement nsIXULAppInfo (e.g. xpcshell doesn't).
|
||||
if (!appVersion && !gApp.version)
|
||||
return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
|
||||
|
||||
if (!appVersion)
|
||||
appVersion = gApp.version;
|
||||
if (!toolkitVersion)
|
||||
toolkitVersion = gApp.platformVersion;
|
||||
|
||||
const pluginProperties = {
|
||||
description: plugin.description,
|
||||
filename: plugin.filename,
|
||||
name: plugin.name,
|
||||
version: plugin.version,
|
||||
};
|
||||
if (!pluginEntries) {
|
||||
Cu.reportError(new Error("There are no plugin entries. This should never happen."));
|
||||
}
|
||||
for (let blockEntry of pluginEntries) {
|
||||
var matchFailed = false;
|
||||
for (var name in blockEntry.matches) {
|
||||
let pluginProperty = pluginProperties[name];
|
||||
if (typeof pluginProperty != "string" ||
|
||||
!blockEntry.matches[name].test(pluginProperty)) {
|
||||
matchFailed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchFailed)
|
||||
continue;
|
||||
|
||||
for (let versionRange of blockEntry.versionRange) {
|
||||
if (Utils.versionsMatch(versionRange, pluginProperties.version,
|
||||
appVersion, toolkitVersion)) {
|
||||
return {entry: blockEntry, version: versionRange};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Private version of getState that allows the caller to pass in
|
||||
* the plugin blocklist entries.
|
||||
*
|
||||
* @param {nsIPluginTag} plugin
|
||||
* The nsIPluginTag to get the blocklist state for.
|
||||
* @param {object[]} pluginEntries
|
||||
* The plugin blocklist entries to compare against.
|
||||
* @param {string?} appVersion
|
||||
* The application version to compare to, will use the current
|
||||
* version if null.
|
||||
* @param {string?} toolkitVersion
|
||||
* The toolkit version to compare to, will use the current version if
|
||||
* null.
|
||||
* @returns {integer}
|
||||
* The blocklist state for the item, one of the STATE constants as
|
||||
* defined in nsIBlocklistService.
|
||||
*/
|
||||
_getState(plugin, pluginEntries, appVersion, toolkitVersion) {
|
||||
let r = this._getEntry(plugin, pluginEntries, appVersion, toolkitVersion);
|
||||
if (!r) {
|
||||
return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
|
||||
}
|
||||
|
||||
let {version: versionRange} = r;
|
||||
|
||||
if (versionRange.severity >= gBlocklistLevel)
|
||||
return Ci.nsIBlocklistService.STATE_BLOCKED;
|
||||
if (versionRange.severity == SEVERITY_OUTDATED) {
|
||||
let vulnerabilityStatus = versionRange.vulnerabilityStatus;
|
||||
if (vulnerabilityStatus == VULNERABILITYSTATUS_UPDATE_AVAILABLE)
|
||||
return Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE;
|
||||
if (vulnerabilityStatus == VULNERABILITYSTATUS_NO_UPDATE)
|
||||
return Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE;
|
||||
return Ci.nsIBlocklistService.STATE_OUTDATED;
|
||||
}
|
||||
return Ci.nsIBlocklistService.STATE_SOFTBLOCKED;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* The extensions blocklist implementation. The JSON objects for extension
|
||||
* blocks look something like:
|
||||
*
|
||||
* {
|
||||
* "guid": "someguid@addons.mozilla.org",
|
||||
* "prefs": ["i.am.a.pref.that.needs.resetting"],
|
||||
* "schema": 1480349193877,
|
||||
* "blockID": "i12345",
|
||||
* "details": {
|
||||
* "bug": "https://bugzilla.mozilla.org/show_bug.cgi?id=1234567",
|
||||
* "who": "All Firefox users who have this add-on installed. If you wish to continue using this add-on, you can enable it in the Add-ons Manager.",
|
||||
* "why": "This add-on is in violation of the <a href=\"https://developer.mozilla.org/en-US/Add-ons/Add-on_guidelines\">Add-on Guidelines</a>, using multiple add-on IDs and potentially doing other unwanted activities.",
|
||||
* "name": "Some pretty name",
|
||||
* "created": "2019-05-06T19:52:20Z"
|
||||
* },
|
||||
* "enabled": true,
|
||||
* "versionRange": [
|
||||
* {
|
||||
* "severity": 1,
|
||||
* "maxVersion": "*",
|
||||
* "minVersion": "0",
|
||||
* "targetApplication": []
|
||||
* }
|
||||
* ],
|
||||
* "id": "<unique guid>",
|
||||
* "last_modified": 1480349215672,
|
||||
* }
|
||||
*
|
||||
* Note: we assign to the global to allow tests to reach the object directly.
|
||||
*/
|
||||
this.ExtensionBlocklistRS = {
|
||||
async _ensureEntries() {
|
||||
await this._ensureInitialized();
|
||||
if (!this._entries && gBlocklistEnabled) {
|
||||
await this._updateEntries();
|
||||
}
|
||||
},
|
||||
|
||||
async _updateEntries() {
|
||||
if (!gBlocklistEnabled) {
|
||||
this._entries = [];
|
||||
return;
|
||||
}
|
||||
this._entries = await this._client.get().catch(ex => Cu.reportError(ex));
|
||||
// Handle error silently. This can happen if our request to fetch data is aborted,
|
||||
// e.g. by application shutdown.
|
||||
if (!this._entries) {
|
||||
this._entries = [];
|
||||
return;
|
||||
}
|
||||
this._entries.forEach(entry => {
|
||||
function getCriteria(str) {
|
||||
if (!str.startsWith("/")) {
|
||||
return str;
|
||||
}
|
||||
let lastSlash = str.lastIndexOf("/");
|
||||
let pattern = str.slice(1, lastSlash);
|
||||
let flags = str.slice(lastSlash + 1);
|
||||
return new RegExp(pattern, flags);
|
||||
}
|
||||
entry.matches = {};
|
||||
if (entry.guid) {
|
||||
entry.matches.id = getCriteria(entry.guid);
|
||||
}
|
||||
for (let key of EXTENSION_BLOCK_FILTERS) {
|
||||
if (key == "id" || !entry[key]) {
|
||||
continue;
|
||||
}
|
||||
entry.matches[key] = getCriteria(entry[key]);
|
||||
}
|
||||
Utils.ensureVersionRangeIsSane(entry);
|
||||
});
|
||||
},
|
||||
|
||||
async _filterItem(entry) {
|
||||
if (!(await BlocklistClients.targetAppFilter(entry, {appID: gAppID, version: gApp.version}))) {
|
||||
return null;
|
||||
}
|
||||
if (!Utils.matchesOSABI(entry)) {
|
||||
return null;
|
||||
}
|
||||
// Need something to filter on - at least a guid or name (either could be a regex):
|
||||
if (!entry.guid && !entry.name) {
|
||||
Cu.reportError(new Error("Nothing to filter add-on item " + entry.blockID + " on"));
|
||||
return null;
|
||||
}
|
||||
return entry;
|
||||
},
|
||||
|
||||
async _ensureInitialized() {
|
||||
if (!gBlocklistEnabled || this._initialized) {
|
||||
return;
|
||||
}
|
||||
this._initialized = true;
|
||||
this._client = RemoteSettings(Services.prefs.getCharPref(PREF_BLOCKLIST_ADDONS_COLLECTION), {
|
||||
bucketNamePref: PREF_BLOCKLIST_BUCKET,
|
||||
lastCheckTimePref: PREF_BLOCKLIST_ADDONS_CHECKED_SECONDS,
|
||||
signerName: Services.prefs.getCharPref(PREF_BLOCKLIST_ADDONS_SIGNER),
|
||||
filterFunc: this._filterItem,
|
||||
});
|
||||
this._onUpdate = this._onUpdate.bind(this);
|
||||
this._client.on("sync", this._onUpdate);
|
||||
},
|
||||
|
||||
shutdown() {
|
||||
if (this._client) {
|
||||
this._client.off("sync", this._onUpdate);
|
||||
}
|
||||
},
|
||||
|
||||
async _onUpdate() {
|
||||
let oldEntries = this._entries || [];
|
||||
await this._ensureInitialized();
|
||||
await this._updateEntries();
|
||||
|
||||
const types = ["extension", "theme", "locale", "dictionary", "service"];
|
||||
let addons = await AddonManager.getAddonsByTypes(types);
|
||||
for (let addon of addons) {
|
||||
let oldState = addon.blocklistState;
|
||||
if (addon.updateBlocklistState) {
|
||||
await addon.updateBlocklistState(false);
|
||||
} else if (oldEntries) {
|
||||
let oldEntry = this._getEntry(addon, oldEntries);
|
||||
oldState = oldEntry ? oldEntry.state : Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
|
||||
} else {
|
||||
oldState = Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
|
||||
}
|
||||
let state = addon.blocklistState;
|
||||
|
||||
LOG("Blocklist state for " + addon.id + " changed from " +
|
||||
oldState + " to " + state);
|
||||
|
||||
// We don't want to re-warn about add-ons
|
||||
if (state == oldState)
|
||||
continue;
|
||||
|
||||
// Ensure that softDisabled is false if the add-on is not soft blocked
|
||||
if (state != Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
|
||||
addon.softDisabled = false;
|
||||
|
||||
// If an add-on has dropped from hard to soft blocked just mark it as
|
||||
// soft disabled and don't warn about it.
|
||||
if (state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED &&
|
||||
oldState == Ci.nsIBlocklistService.STATE_BLOCKED) {
|
||||
addon.softDisabled = true;
|
||||
}
|
||||
|
||||
if (state == Ci.nsIBlocklistService.STATE_BLOCKED ||
|
||||
state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED) {
|
||||
// Mark it as softblocked if necessary. Note that we avoid setting
|
||||
// softDisabled at the same time as userDisabled to make it clear
|
||||
// which was the original cause of the add-on becoming disabled in a
|
||||
// way that the user can change.
|
||||
if (state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED && !addon.userDisabled)
|
||||
addon.softDisabled = true;
|
||||
// It's a block. We must reset certain preferences.
|
||||
let entry = this._getEntry(addon, this._entries);
|
||||
if (entry.prefs && entry.prefs.length) {
|
||||
for (let pref of entry.prefs) {
|
||||
Services.prefs.clearUserPref(pref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AddonManagerPrivate.updateAddonAppDisabledStates();
|
||||
},
|
||||
|
||||
async getState(addon, appVersion, toolkitVersion) {
|
||||
let entry = await this.getEntry(addon, appVersion, toolkitVersion);
|
||||
return entry ? entry.state : Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
|
||||
},
|
||||
|
||||
async getEntry(addon, appVersion, toolkitVersion) {
|
||||
await this._ensureEntries();
|
||||
return this._getEntry(addon, this._entries, appVersion, toolkitVersion);
|
||||
},
|
||||
|
||||
_getEntry(addon, addonEntries, appVersion, toolkitVersion) {
|
||||
if (!gBlocklistEnabled || !addon)
|
||||
return null;
|
||||
|
||||
// Not all applications implement nsIXULAppInfo (e.g. xpcshell doesn't).
|
||||
if (!appVersion && !gApp.version)
|
||||
return null;
|
||||
|
||||
if (!appVersion)
|
||||
appVersion = gApp.version;
|
||||
if (!toolkitVersion)
|
||||
toolkitVersion = gApp.platformVersion;
|
||||
|
||||
let addonProps = {};
|
||||
for (let key of EXTENSION_BLOCK_FILTERS) {
|
||||
addonProps[key] = addon[key];
|
||||
}
|
||||
if (addonProps.creator)
|
||||
addonProps.creator = addonProps.creator.name;
|
||||
|
||||
let propMatches = ([k, v]) => {
|
||||
return !v || addonProps[k] == v || ((v instanceof RegExp) && v.test(addonProps[k]));
|
||||
};
|
||||
for (let entry of addonEntries) {
|
||||
// First check if it matches our properties. If not, just skip to the next item.
|
||||
if (!Object.entries(entry.matches).every(propMatches)) {
|
||||
continue;
|
||||
}
|
||||
// If those match, check the app or toolkit version works:
|
||||
for (let versionRange of entry.versionRange) {
|
||||
if (Utils.versionsMatch(versionRange, addon.version,
|
||||
appVersion, toolkitVersion)) {
|
||||
return {
|
||||
state: versionRange.severity >= gBlocklistLevel ?
|
||||
Ci.nsIBlocklistService.STATE_BLOCKED : Ci.nsIBlocklistService.STATE_SOFTBLOCKED,
|
||||
url: entry.blockID && Utils._createBlocklistURL(entry.blockID),
|
||||
prefs: entry.prefs || [],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
const EXTENSION_BLOCK_FILTERS = ["id", "name", "creator", "homepageURL", "updateURL"];
|
||||
|
||||
var gLoggingEnabled = null;
|
||||
|
@ -311,10 +1063,12 @@ XPCOMUtils.defineLazyGetter(this, "gApp", function() {
|
|||
XPCOMUtils.defineLazyGetter(this, "gAppID", function() {
|
||||
return gApp.ID;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gAppVersion", function() {
|
||||
return gApp.version;
|
||||
});
|
||||
XPCOMUtils.defineLazyGetter(this, "gAppOS", function() {
|
||||
return gApp.OS;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gABI", function() {
|
||||
let abi = null;
|
||||
|
@ -400,16 +1154,6 @@ function matchesOSABI(blocklistElement) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current value of the locale. It's possible for this preference to
|
||||
* be localized, so we have to do a little extra work here. Similar code
|
||||
* exists in nsHttpHandler.cpp when building the UA string.
|
||||
*
|
||||
* @returns {string} The current requested locale.
|
||||
*/
|
||||
function getLocale() {
|
||||
return Services.locale.requestedLocale;
|
||||
}
|
||||
|
||||
/* Get the distribution pref values, from defaults only */
|
||||
function getDistributionPrefValue(aPrefName) {
|
||||
|
@ -705,7 +1449,7 @@ var BlocklistXML = {
|
|||
BUILD_ID: gApp.appBuildID,
|
||||
BUILD_TARGET: gApp.OS + "_" + gABI,
|
||||
OS_VERSION: gOSVersion,
|
||||
LOCALE: getLocale(),
|
||||
LOCALE: Services.locale.requestedLocale,
|
||||
CHANNEL: UpdateUtils.UpdateChannel,
|
||||
PLATFORM_VERSION: gApp.platformVersion,
|
||||
DISTRIBUTION: getDistributionPrefValue(PREF_APP_DISTRIBUTION),
|
||||
|
@ -1355,7 +2099,8 @@ var BlocklistXML = {
|
|||
},
|
||||
|
||||
_notifyObserversBlocklistUpdated() {
|
||||
Services.obs.notifyObservers(this, "blocklist-updated");
|
||||
Services.obs.notifyObservers(this, "addon-blocklist-updated");
|
||||
Services.obs.notifyObservers(this, "plugin-blocklist-updated");
|
||||
},
|
||||
|
||||
async _blocklistUpdated(oldAddonEntries, oldPluginEntries) {
|
||||
|
@ -1707,6 +2452,8 @@ let BlocklistRS = {
|
|||
},
|
||||
shutdown() {
|
||||
GfxBlocklistRS.shutdown();
|
||||
PluginBlocklistRS.shutdown();
|
||||
ExtensionBlocklistRS.shutdown();
|
||||
},
|
||||
isLoaded: true,
|
||||
|
||||
|
@ -1723,19 +2470,25 @@ let BlocklistRS = {
|
|||
gLoadingWasTriggered = true;
|
||||
},
|
||||
|
||||
getPluginBlocklistState() {
|
||||
getPluginBlocklistState(plugin, appVersion, toolkitVersion) {
|
||||
return PluginBlocklistRS.getState(plugin, appVersion, toolkitVersion);
|
||||
},
|
||||
|
||||
getPluginBlockURL() {
|
||||
getPluginBlockURL(plugin) {
|
||||
return PluginBlocklistRS.getURL(plugin);
|
||||
},
|
||||
|
||||
getAddonBlocklistState() {
|
||||
getAddonBlocklistState(addon, appVersion, toolkitVersion) {
|
||||
return ExtensionBlocklistRS.getState(addon, appVersion, toolkitVersion);
|
||||
},
|
||||
|
||||
getAddonBlocklistEntry() {
|
||||
getAddonBlocklistEntry(addon, appVersion, toolkitVersion) {
|
||||
return ExtensionBlocklistRS.getEntry(addon, appVersion, toolkitVersion);
|
||||
},
|
||||
|
||||
_blocklistUpdated(oldAddons, oldPlugins) {
|
||||
_blocklistUpdated() {
|
||||
ExtensionBlocklistRS._onUpdate();
|
||||
PluginBlocklistRS._onUpdate();
|
||||
},
|
||||
|
||||
initializeClients() {
|
||||
|
@ -1794,6 +2547,7 @@ let Blocklist = {
|
|||
},
|
||||
|
||||
shutdown() {
|
||||
this._impl.shutdown();
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
Services.prefs.removeObserver("extensions.blocklist.", this);
|
||||
Services.prefs.removeObserver(PREF_EM_LOGGING_ENABLED, this);
|
||||
|
@ -1821,6 +2575,8 @@ let Blocklist = {
|
|||
// so check:
|
||||
if (this._impl == BlocklistXML) {
|
||||
this._impl._onBlocklistEnabledToggle();
|
||||
} else {
|
||||
this._impl._blocklistUpdated();
|
||||
}
|
||||
break;
|
||||
case PREF_BLOCKLIST_LEVEL:
|
||||
|
|
|
@ -708,6 +708,60 @@ var AddonTestUtils = {
|
|||
return mock;
|
||||
},
|
||||
|
||||
/**
|
||||
* Load the following data into the *real* blocklist providers.
|
||||
* While `overrideBlocklist` replaces the blocklist entirely with a mock
|
||||
* that returns dummy data, this method instead loads data into the actual
|
||||
* blocklist, fires update methods as would happen if this data came from
|
||||
* an actual blocklist update, etc.
|
||||
*
|
||||
* @param {nsIFile} dir
|
||||
* The directory in which the files live.
|
||||
* @param {string} prefix
|
||||
* a prefix for the files which ought to be loaded.
|
||||
* This method will suffix -extensions.json and -plugins.json
|
||||
* to the prefix it is given, and attempt to load both.
|
||||
* Insofar as either exists, their data will be dumped into
|
||||
* the respective store, and the respective update handlers
|
||||
* will be called.
|
||||
*/
|
||||
async loadBlocklistData(dir, prefix) {
|
||||
const bsPass = ChromeUtils.import("resource://gre/modules/Blocklist.jsm", null);
|
||||
const blocklistMapping = {
|
||||
"extensions": bsPass.ExtensionBlocklistRS,
|
||||
"plugins": bsPass.PluginBlocklistRS,
|
||||
};
|
||||
|
||||
for (const [fileSuffix, blocklistObj] of Object.entries(blocklistMapping)) {
|
||||
const fileName = `${prefix}-${fileSuffix}.json`;
|
||||
let jsonStr = await OS.File.read(OS.Path.join(dir.path, fileName), {encoding: "UTF-8"}).catch(() => {});
|
||||
if (!jsonStr) {
|
||||
continue;
|
||||
}
|
||||
this.info(`Loading ${fileName}`);
|
||||
|
||||
let newData = JSON.parse(jsonStr);
|
||||
if (!Array.isArray(newData)) {
|
||||
throw new Error("Expected an array of new items to put in the " + fileSuffix + " blocklist!");
|
||||
}
|
||||
for (let item of newData) {
|
||||
if (!item.id) {
|
||||
item.id = uuidGen.generateUUID().number.slice(1, -1);
|
||||
}
|
||||
if (!item.last_modified) {
|
||||
item.last_modified = Date.now();
|
||||
}
|
||||
}
|
||||
await blocklistObj._ensureInitialized();
|
||||
let collection = await blocklistObj._client.openCollection();
|
||||
await collection.clear();
|
||||
await collection.loadDump(newData);
|
||||
// We manually call _onUpdate... which is evil, but at the moment kinto doesn't have
|
||||
// a better abstraction unless you want to mock your own http server to do the update.
|
||||
await blocklistObj._onUpdate();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Starts up the add-on manager as if it was started by the application.
|
||||
*
|
||||
|
|
|
@ -4,15 +4,17 @@ function updateBlocklist(aCallback) {
|
|||
var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
|
||||
.getService(Ci.nsITimerCallback);
|
||||
var observer = function() {
|
||||
Services.obs.removeObserver(observer, "blocklist-updated");
|
||||
Services.obs.removeObserver(observer, "plugin-blocklist-updated");
|
||||
SimpleTest.executeSoon(aCallback);
|
||||
};
|
||||
Services.obs.addObserver(observer, "blocklist-updated");
|
||||
Services.obs.addObserver(observer, "plugin-blocklist-updated");
|
||||
blocklistNotifier.notify(null);
|
||||
}
|
||||
|
||||
var _originalBlocklistURL = null;
|
||||
function setAndUpdateBlocklist(aURL, aCallback) {
|
||||
// FIXME needs to change blocklist differently.
|
||||
// Tracked in https://bugzilla.mozilla.org/show_bug.cgi?id=1549548 .
|
||||
if (!_originalBlocklistURL) {
|
||||
_originalBlocklistURL = Services.prefs.getCharPref("extensions.blocklist.url");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
[
|
||||
{
|
||||
"guid": "softblock1@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock2@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock3@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock4@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock5@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "hardblock@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Two RegExp matches, so test flags work - first shouldn't match.",
|
||||
"guid": "/^RegExp/",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "/^RegExp/i",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2",
|
||||
"severity": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,120 @@
|
|||
[
|
||||
{
|
||||
"guid": "softblock1@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock2@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock3@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock4@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock5@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "hardblock@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "/^RegExp/",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "/^RegExp/i",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
[ ]
|
|
@ -0,0 +1,58 @@
|
|||
[
|
||||
{
|
||||
"guid": "softblock1@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock2@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock3@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock4@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock5@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "hardblock@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "/^RegExp/",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "/^RegExp/i",
|
||||
"versionRange": []
|
||||
}
|
||||
]
|
|
@ -0,0 +1,70 @@
|
|||
[
|
||||
{
|
||||
"guid": "softblock1@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "1",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock2@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "1",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock3@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "1",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock4@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "1",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "softblock5@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "1",
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "hardblock@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "/^RegExp/i",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,37 @@
|
|||
[
|
||||
{
|
||||
"guid": "test_bug455906_1@tests.mozilla.org",
|
||||
"blockID": "test_bug455906_1@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_2@tests.mozilla.org",
|
||||
"blockID": "test_bug455906_2@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_3@tests.mozilla.org",
|
||||
"blockID": "test_bug455906_3@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_4@tests.mozilla.org",
|
||||
"blockID": "test_bug455906_4@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_5@tests.mozilla.org",
|
||||
"blockID": "test_bug455906_5@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_6@tests.mozilla.org",
|
||||
"blockID": "test_bug455906_6@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_7@tests.mozilla.org",
|
||||
"blockID": "test_bug455906_7@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
}
|
||||
]
|
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
{
|
||||
"matchName": "^test_bug455906",
|
||||
"versionRange": [],
|
||||
"blockID": "test_bug455906_plugin"
|
||||
}
|
||||
]
|
|
@ -0,0 +1,6 @@
|
|||
[
|
||||
{
|
||||
"guid": "dummy_bug455906_2@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
}
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
[ ]
|
|
@ -0,0 +1,30 @@
|
|||
[
|
||||
{
|
||||
"guid": "test_bug455906_4@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_5@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_6@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "dummy_bug455906_1@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
}
|
||||
]
|
|
@ -0,0 +1,26 @@
|
|||
[
|
||||
{
|
||||
"matchName": "^test_bug455906_4$",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug455906_5$",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug455906_6$",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,58 @@
|
|||
[
|
||||
{
|
||||
"guid": "test_bug455906_1@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_2@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_3@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_4@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_5@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_6@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug455906_7@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "-1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
{
|
||||
"matchName": "^test_bug455906",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "-1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,69 @@
|
|||
[
|
||||
{
|
||||
"matchName": "^test_with_infoURL",
|
||||
"matchVersion": "^5",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "*",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"blockID": "test_plugin_wInfoURL",
|
||||
"infoURL": "http://test.url.com/"
|
||||
},
|
||||
{
|
||||
"matchName": "^test_with_altInfoURL",
|
||||
"matchVersion": "^5",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "*",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"blockID": "test_plugin_wAltInfoURL",
|
||||
"infoURL": "http://alt.test.url.com/"
|
||||
},
|
||||
{
|
||||
"matchName": "^test_no_infoURL",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "*",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"blockID": "test_plugin_noInfoURL"
|
||||
},
|
||||
{
|
||||
"matchName": "^test_newVersion",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "1",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "*",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"blockID": "test_plugin_newVersion",
|
||||
"infoURL": "http://test.url2.com/"
|
||||
}
|
||||
]
|
|
@ -0,0 +1,36 @@
|
|||
[
|
||||
{
|
||||
"guid": null,
|
||||
"name": "/^Mozilla Corp\\.$/",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "/block2/",
|
||||
"name": "/^Moz/",
|
||||
"homepageURL": "/\\.dangerous\\.com/",
|
||||
"updateURL": "/\\.dangerous\\.com/",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "3",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,40 @@
|
|||
[
|
||||
{
|
||||
"guid": "block1@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"prefs": [
|
||||
"test.blocklist.pref1",
|
||||
"test.blocklist.pref2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "block2@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "3",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2.*",
|
||||
"minVersion": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"prefs": [
|
||||
"test.blocklist.pref3",
|
||||
"test.blocklist.pref4"
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,94 @@
|
|||
[
|
||||
{
|
||||
"guid": "test_bug393285_2@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_3a@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "1.0",
|
||||
"minVersion": "1.0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_3b@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "1.0",
|
||||
"minVersion": "1.0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_4@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "1.0",
|
||||
"minVersion": "1.0",
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "1.0",
|
||||
"minVersion": "1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_5@tests.mozilla.org",
|
||||
"os": "Darwin",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_6@tests.mozilla.org",
|
||||
"os": "XPCShell",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_7@tests.mozilla.org",
|
||||
"os": "Darwin,XPCShell,WINNT",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_8@tests.mozilla.org",
|
||||
"xpcomabi": "x86-msvc",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_9@tests.mozilla.org",
|
||||
"xpcomabi": "noarch-spidermonkey",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_10@tests.mozilla.org",
|
||||
"xpcomabi": "ppc-gcc3,noarch-spidermonkey,x86-msvc",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_11@tests.mozilla.org",
|
||||
"os": "Darwin",
|
||||
"xpcomabi": "ppc-gcc3,x86-msvc",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_12@tests.mozilla.org",
|
||||
"os": "Darwin",
|
||||
"xpcomabi": "ppc-gcc3,noarch-spidermonkey,x86-msvc",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_13@tests.mozilla.org",
|
||||
"os": "XPCShell",
|
||||
"xpcomabi": "ppc-gcc3,x86-msvc",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"guid": "test_bug393285_14@tests.mozilla.org",
|
||||
"os": "XPCShell,WINNT",
|
||||
"xpcomabi": "ppc-gcc3,x86-msvc,noarch-spidermonkey",
|
||||
"versionRange": []
|
||||
}
|
||||
]
|
|
@ -0,0 +1,336 @@
|
|||
[
|
||||
{
|
||||
"_comment": "Always blocked",
|
||||
"guid": "test_bug449027_2@tests.mozilla.org",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"_comment": "Always blocked",
|
||||
"guid": "test_bug449027_3@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Not blocked since neither version range matches",
|
||||
"guid": "test_bug449027_4@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"minVersion": "6"
|
||||
},
|
||||
{
|
||||
"maxVersion": "4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Invalid version range, should not block",
|
||||
"guid": "test_bug449027_5@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "4",
|
||||
"minVersion": "6"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Should block all of these",
|
||||
"guid": "test_bug449027_6@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "8",
|
||||
"minVersion": "7"
|
||||
},
|
||||
{
|
||||
"maxVersion": "6",
|
||||
"minVersion": "5"
|
||||
},
|
||||
{
|
||||
"maxVersion": "4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_7@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "4"
|
||||
},
|
||||
{
|
||||
"maxVersion": "5",
|
||||
"minVersion": "4"
|
||||
},
|
||||
{
|
||||
"maxVersion": "7",
|
||||
"minVersion": "6"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_8@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "2"
|
||||
},
|
||||
{
|
||||
"maxVersion": "6",
|
||||
"minVersion": "4"
|
||||
},
|
||||
{
|
||||
"maxVersion": "8",
|
||||
"minVersion": "7"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_9@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"minVersion": "4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_10@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"minVersion": "5"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_11@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "6"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_12@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "5"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "This should block all versions for any application",
|
||||
"guid": "test_bug449027_13@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Shouldn't block",
|
||||
"guid": "test_bug449027_14@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Should block for any version of the app",
|
||||
"guid": "test_bug449027_15@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Should still block",
|
||||
"guid": "test_bug449027_16@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Not blocked since neither version range matches",
|
||||
"guid": "test_bug449027_17@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"minVersion": "4"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Invalid version range, should not block",
|
||||
"guid": "test_bug449027_18@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "4",
|
||||
"minVersion": "6"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Should block all of these",
|
||||
"guid": "test_bug449027_19@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "6",
|
||||
"minVersion": "5"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "4",
|
||||
"minVersion": "3"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_20@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "5",
|
||||
"minVersion": "4"
|
||||
},
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_21@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "1",
|
||||
"minVersion": "1"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "4",
|
||||
"minVersion": "2"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "6",
|
||||
"minVersion": "5"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_22@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"minVersion": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_23@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"minVersion": "2"
|
||||
},
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_24@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_25@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "4"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,336 @@
|
|||
[
|
||||
{
|
||||
"_comment": "Always blocked",
|
||||
"matchName": "^test_bug449027_2$",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"_comment": "Always blocked",
|
||||
"matchName": "^test_bug449027_3$",
|
||||
"versionRange": [
|
||||
{}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Not blocked since neither version range matches",
|
||||
"matchName": "^test_bug449027_4$",
|
||||
"versionRange": [
|
||||
{
|
||||
"minVersion": "6"
|
||||
},
|
||||
{
|
||||
"maxVersion": "4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Invalid version range, should not block",
|
||||
"matchName": "^test_bug449027_5$",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "4",
|
||||
"minVersion": "6"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Should block all of these",
|
||||
"matchName": "^test_bug449027_6$",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "8",
|
||||
"minVersion": "7"
|
||||
},
|
||||
{
|
||||
"maxVersion": "6",
|
||||
"minVersion": "5"
|
||||
},
|
||||
{
|
||||
"maxVersion": "4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_7$",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "4"
|
||||
},
|
||||
{
|
||||
"maxVersion": "5",
|
||||
"minVersion": "4"
|
||||
},
|
||||
{
|
||||
"maxVersion": "7",
|
||||
"minVersion": "6"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_8$",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "2",
|
||||
"minVersion": "2"
|
||||
},
|
||||
{
|
||||
"maxVersion": "6",
|
||||
"minVersion": "4"
|
||||
},
|
||||
{
|
||||
"maxVersion": "8",
|
||||
"minVersion": "7"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_9$",
|
||||
"versionRange": [
|
||||
{
|
||||
"minVersion": "4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_10$",
|
||||
"versionRange": [
|
||||
{
|
||||
"minVersion": "5"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_11$",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "6"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_12$",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "5"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "This should block all versions for any application",
|
||||
"matchName": "^test_bug449027_13$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Shouldn't block",
|
||||
"matchName": "^test_bug449027_14$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Should block for any version of the app",
|
||||
"matchName": "^test_bug449027_15$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Should still block",
|
||||
"matchName": "^test_bug449027_16$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Not blocked since neither version range matches",
|
||||
"matchName": "^test_bug449027_17$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"minVersion": "4"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Invalid version range, should not block",
|
||||
"matchName": "^test_bug449027_18$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "4",
|
||||
"minVersion": "6"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"_comment": "Should block all of these",
|
||||
"matchName": "^test_bug449027_19$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "6",
|
||||
"minVersion": "5"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "4",
|
||||
"minVersion": "3"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_20$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "2"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "3",
|
||||
"minVersion": "2"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "5",
|
||||
"minVersion": "4"
|
||||
},
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_21$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "1",
|
||||
"minVersion": "1"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "4",
|
||||
"minVersion": "2"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "6",
|
||||
"minVersion": "5"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_22$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
},
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"minVersion": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_23$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"minVersion": "2"
|
||||
},
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_24$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_25$",
|
||||
"versionRange": [
|
||||
{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "xpcshell@tests.mozilla.org",
|
||||
"maxVersion": "4"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,154 @@
|
|||
[
|
||||
{
|
||||
"_general_comment": "All extensions are version 5 and tests run against toolkitVersion 8",
|
||||
"_general_comment2": "Test 1-14 not listed, should never get blocked",
|
||||
|
||||
"_comment": "Should block for any version of the app",
|
||||
"guid": "test_bug449027_15@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{"guid": "toolkit@mozilla.org"}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"_comment": "Should still block",
|
||||
"guid": "test_bug449027_16@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{"guid": "toolkit@mozilla.org"}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"_comment": "Not blocked since neither version range matches",
|
||||
"guid": "test_bug449027_17@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"minVersion": "9",
|
||||
"guid": "toolkit@mozilla.org"
|
||||
},{
|
||||
"maxVersion": "7",
|
||||
"guid": "toolkit@mozilla.org"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"_comment": "Invalid version range, should not block",
|
||||
"guid": "test_bug449027_18@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"minVersion": "11",
|
||||
"maxVersion": "9",
|
||||
"guid": "toolkit@mozilla.org"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"_comment": "Should block all of the following",
|
||||
"guid": "test_bug449027_19@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "10",
|
||||
"maxVersion": "11"
|
||||
},
|
||||
{
|
||||
"minVersion": "8",
|
||||
"maxVersion": "9"
|
||||
},
|
||||
{
|
||||
"maxVersion": "7"
|
||||
}
|
||||
]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_20@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"maxVersion": "7"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "7",
|
||||
"maxVersion": "8"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "9",
|
||||
"maxVersion": "10"
|
||||
},
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}
|
||||
]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_21@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "6",
|
||||
"maxVersion": "6"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "7",
|
||||
"maxVersion": "9"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "10",
|
||||
"maxVersion": "11"
|
||||
}
|
||||
]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_22@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"guid": "foo@bar.com"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "8"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_23@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "7"
|
||||
},
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_24@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"maxVersion": "8",
|
||||
"guid": "toolkit@mozilla.org"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"guid": "test_bug449027_25@tests.mozilla.org",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"maxVersion": "9"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,155 @@
|
|||
[
|
||||
{
|
||||
"_general_comment": "All plugins are version 5 and tests run against appVersion 3",
|
||||
"_general_comment2": "Test 1-14 not listed, should never get blocked",
|
||||
|
||||
"_comment": "Should block for any version of the app",
|
||||
"matchName": "^test_bug449027_15$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{"guid": "toolkit@mozilla.org"}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"_comment": "Should still block",
|
||||
"matchName": "^test_bug449027_16$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{"guid": "toolkit@mozilla.org"}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"_comment": "Not blocked since neither version range matches",
|
||||
"matchName": "^test_bug449027_17$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"minVersion": "9",
|
||||
"guid": "toolkit@mozilla.org"
|
||||
},{
|
||||
"maxVersion": "7",
|
||||
"guid": "toolkit@mozilla.org"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"_comment": "Invalid version range, should not block",
|
||||
"matchName": "^test_bug449027_18$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"minVersion": "11",
|
||||
"maxVersion": "9",
|
||||
"guid": "toolkit@mozilla.org"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"_comment": "Should block all of the following",
|
||||
"matchName": "^test_bug449027_19$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "10",
|
||||
"maxVersion": "11"
|
||||
},
|
||||
{
|
||||
"minVersion": "8",
|
||||
"maxVersion": "9"
|
||||
},
|
||||
{
|
||||
"maxVersion": "7"
|
||||
}
|
||||
]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_20$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"maxVersion": "7"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "7",
|
||||
"maxVersion": "8"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "9",
|
||||
"maxVersion": "10"
|
||||
},
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}
|
||||
]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_21$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "6",
|
||||
"maxVersion": "6"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "7",
|
||||
"maxVersion": "9"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "10",
|
||||
"maxVersion": "11"
|
||||
}
|
||||
]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_22$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"guid": "foo@bar.com"
|
||||
},
|
||||
{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "8"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_23$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"minVersion": "7"
|
||||
},
|
||||
{
|
||||
"guid": "foo@bar.com"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_24$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"maxVersion": "8",
|
||||
"guid": "toolkit@mozilla.org"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug449027_25$",
|
||||
"versionRange": [{
|
||||
"targetApplication": [{
|
||||
"guid": "toolkit@mozilla.org",
|
||||
"maxVersion": "9"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
[
|
||||
{
|
||||
"matchName": "^test_bug514327_1",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug514327_2",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_bug514327_3",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
{
|
||||
"matchName": "Test Plug-in",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
[ ]
|
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
{
|
||||
"matchName": "test_bug514327_1",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"matchName": "test_bug514327_outdated",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
{
|
||||
"matchName": "test_bug514327_2",
|
||||
"versionRange": []
|
||||
},
|
||||
{
|
||||
"matchName": "test_bug514327_outdated",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,56 @@
|
|||
[
|
||||
{
|
||||
"matchName": "^test_plugin_0",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "*",
|
||||
"minVersion": "0",
|
||||
"severity": "0",
|
||||
"vulnerabilityStatus": "0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_plugin_1",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "*",
|
||||
"minVersion": "0",
|
||||
"severity": "0",
|
||||
"vulnerabilityStatus": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_plugin_2",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "*",
|
||||
"minVersion": "0",
|
||||
"severity": "0",
|
||||
"vulnerabilityStatus": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_plugin_3",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "*",
|
||||
"minVersion": "0",
|
||||
"vulnerabilityStatus": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matchName": "^test_plugin_4",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "*",
|
||||
"minVersion": "0",
|
||||
"severity": "1",
|
||||
"vulnerabilityStatus": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,13 @@
|
|||
[
|
||||
{
|
||||
"matchName": "^Test Plug-in",
|
||||
"versionRange": [
|
||||
{
|
||||
"maxVersion": "*",
|
||||
"minVersion": "0",
|
||||
"severity": "0",
|
||||
"vulnerabilityStatus": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
{
|
||||
"guid": "softblock1@tests.mozilla.org",
|
||||
"versionRange": [
|
||||
{
|
||||
"severity": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,323 @@
|
|||
/* 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 Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
|
||||
var ADDONS = [{
|
||||
id: "test_bug449027_1@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 1",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_2@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 2",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_3@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 3",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_4@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 4",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_5@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 5",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_6@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 6",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_7@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 7",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_8@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 8",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_9@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 9",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_10@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 10",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_11@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 11",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_12@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 12",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_13@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 13",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_14@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 14",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_15@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 15",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true,
|
||||
}, {
|
||||
id: "test_bug449027_16@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 16",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true,
|
||||
}, {
|
||||
id: "test_bug449027_17@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 17",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_18@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 18",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: false,
|
||||
toolkitBlocks: false,
|
||||
}, {
|
||||
id: "test_bug449027_19@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 19",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true,
|
||||
}, {
|
||||
id: "test_bug449027_20@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 20",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true,
|
||||
}, {
|
||||
id: "test_bug449027_21@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 21",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true,
|
||||
}, {
|
||||
id: "test_bug449027_22@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 22",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true,
|
||||
}, {
|
||||
id: "test_bug449027_23@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 23",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true,
|
||||
}, {
|
||||
id: "test_bug449027_24@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 24",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true,
|
||||
}, {
|
||||
id: "test_bug449027_25@tests.mozilla.org",
|
||||
name: "Bug 449027 Addon Test 25",
|
||||
version: "5",
|
||||
start: false,
|
||||
appBlocks: true,
|
||||
toolkitBlocks: true,
|
||||
}];
|
||||
|
||||
class MockPlugin extends MockPluginTag {
|
||||
constructor(name, version, start, appBlocks, toolkitBlocks) {
|
||||
super({name, version});
|
||||
this.start = start;
|
||||
this.appBlocks = appBlocks;
|
||||
this.toolkitBlocks = toolkitBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
var PLUGINS = [
|
||||
new MockPlugin("test_bug449027_1", "5", false, false, false),
|
||||
new MockPlugin("test_bug449027_2", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_3", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_4", "5", false, false, false),
|
||||
new MockPlugin("test_bug449027_5", "5", false, false, false),
|
||||
new MockPlugin("test_bug449027_6", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_7", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_8", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_9", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_10", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_11", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_12", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_13", "5", false, true, false),
|
||||
new MockPlugin("test_bug449027_14", "5", false, false, false),
|
||||
new MockPlugin("test_bug449027_15", "5", false, true, true),
|
||||
new MockPlugin("test_bug449027_16", "5", false, true, true),
|
||||
new MockPlugin("test_bug449027_17", "5", false, false, false),
|
||||
new MockPlugin("test_bug449027_18", "5", false, false, false),
|
||||
new MockPlugin("test_bug449027_19", "5", false, true, true),
|
||||
new MockPlugin("test_bug449027_20", "5", false, true, true),
|
||||
new MockPlugin("test_bug449027_21", "5", false, true, true),
|
||||
new MockPlugin("test_bug449027_22", "5", false, true, true),
|
||||
new MockPlugin("test_bug449027_23", "5", false, true, true),
|
||||
new MockPlugin("test_bug449027_24", "5", false, true, true),
|
||||
new MockPlugin("test_bug449027_25", "5", false, true, true),
|
||||
];
|
||||
|
||||
var gNewBlocks = [];
|
||||
|
||||
mockPluginHost(PLUGINS);
|
||||
|
||||
var BlocklistPrompt = {
|
||||
get wrappedJSObject() { return this; },
|
||||
|
||||
prompt(list) {
|
||||
gNewBlocks = list.map(item => `${item.name} ${item.version}`);
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([]),
|
||||
};
|
||||
|
||||
|
||||
let factory = XPCOMUtils.generateSingletonFactory(function() { return BlocklistPrompt; });
|
||||
Cm.registerFactory(Components.ID("{26d32654-30c7-485d-b983-b4d2568aebba}"),
|
||||
"Blocklist Prompt",
|
||||
"@mozilla.org/addons/blocklist-prompt;1", factory);
|
||||
|
||||
function createAddon(addon) {
|
||||
return promiseInstallWebExtension({
|
||||
manifest: {
|
||||
name: addon.name,
|
||||
version: addon.version,
|
||||
applications: {gecko: {id: addon.id}},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that items are blocklisted correctly according to the current test.
|
||||
* If a lastTest is provided checks that the notification dialog got passed
|
||||
* the newly blocked items compared to the previous test.
|
||||
*/
|
||||
async function checkState(test, lastTest, callback) {
|
||||
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
|
||||
|
||||
const bls = Ci.nsIBlocklistService;
|
||||
|
||||
await TestUtils.waitForCondition(
|
||||
() => ADDONS.every((addon, i) => addon[test] == (addons[i].blocklistState == bls.STATE_BLOCKED))
|
||||
).catch(() => { /* ignore exceptions; the following test will fail anyway. */ });
|
||||
|
||||
for (let [i, addon] of ADDONS.entries()) {
|
||||
var blocked = addons[i].blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED;
|
||||
equal(blocked, addon[test],
|
||||
`Blocklist state should match expected for extension ${addon.id}, test ${test}`);
|
||||
}
|
||||
|
||||
for (let plugin of PLUGINS) {
|
||||
equal(await plugin.isBlocklisted(), plugin[test],
|
||||
`Blocklist state should match expected for plugin ${plugin.name}, test ${test}`);
|
||||
}
|
||||
|
||||
if (lastTest) {
|
||||
var expected = 0;
|
||||
for (let plugin of PLUGINS) {
|
||||
if (plugin[test] && !plugin[lastTest]) {
|
||||
ok(gNewBlocks.includes(`${plugin.name} ${plugin.version}`),
|
||||
`Plugin ${plugin.name} should have been listed in the blocklist notification for test ${test}`);
|
||||
expected++;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.equal(expected, gNewBlocks.length);
|
||||
}
|
||||
}
|
||||
|
||||
add_task(async function test() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
|
||||
await promiseStartupManager();
|
||||
|
||||
for (let addon of ADDONS) {
|
||||
await createAddon(addon);
|
||||
}
|
||||
|
||||
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
|
||||
for (var i = 0; i < ADDONS.length; i++) {
|
||||
ok(addons[i], `Addon ${i + 1} should have been correctly installed`);
|
||||
}
|
||||
|
||||
await checkState("start");
|
||||
});
|
||||
|
||||
/**
|
||||
* Load the toolkit based blocks
|
||||
*/
|
||||
add_task(async function test_pt2() {
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data/"), "test_bug449027_toolkit");
|
||||
|
||||
await checkState("toolkitBlocks", "start");
|
||||
});
|
||||
|
||||
/**
|
||||
* Load the application based blocks
|
||||
*/
|
||||
add_task(async function test_pt3() {
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data/"), "test_bug449027_app");
|
||||
|
||||
await checkState("appBlocks", "toolkitBlocks");
|
||||
});
|
|
@ -0,0 +1,73 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests blocking of extensions by ID, name, creator, homepageURL, updateURL
|
||||
// and RegExps for each. See bug 897735.
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
|
||||
|
||||
await promiseStartupManager();
|
||||
|
||||
// Should get blocked by name
|
||||
await promiseInstallWebExtension({
|
||||
manifest: {
|
||||
name: "Mozilla Corp.",
|
||||
version: "1.0",
|
||||
applications: {gecko: {id: "block1@tests.mozilla.org"}},
|
||||
},
|
||||
});
|
||||
|
||||
// Should get blocked by all the attributes.
|
||||
await promiseInstallWebExtension({
|
||||
manifest: {
|
||||
name: "Moz-addon",
|
||||
version: "1.0",
|
||||
homepage_url: "https://www.extension.dangerous.com/",
|
||||
applications: {
|
||||
gecko: {
|
||||
id: "block2@tests.mozilla.org",
|
||||
update_url: "https://www.extension.dangerous.com/update.json",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Fails to get blocked because of a different ID even though other
|
||||
// attributes match against a blocklist entry.
|
||||
await promiseInstallWebExtension({
|
||||
manifest: {
|
||||
name: "Moz-addon",
|
||||
version: "1.0",
|
||||
homepage_url: "https://www.extension.dangerous.com/",
|
||||
applications: {
|
||||
gecko: {
|
||||
id: "block3@tests.mozilla.org",
|
||||
update_url: "https://www.extension.dangerous.com/update.json",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
let [a1, a2, a3] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
|
||||
"block2@tests.mozilla.org",
|
||||
"block3@tests.mozilla.org"]);
|
||||
Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
Assert.equal(a3.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function test_blocks() {
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data/"), "test_blocklist_metadata_filters_1");
|
||||
|
||||
let [a1, a2, a3] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
|
||||
"block2@tests.mozilla.org",
|
||||
"block3@tests.mozilla.org"]);
|
||||
Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
Assert.equal(a3.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
});
|
|
@ -0,0 +1,175 @@
|
|||
/* 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 profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
const ADDONS = [
|
||||
{
|
||||
id: "test_bug393285_1@tests.mozilla.org",
|
||||
name: "extension 1",
|
||||
version: "1.0",
|
||||
|
||||
// No info in blocklist, shouldn't be blocked
|
||||
notBlocklisted: [["1", "1.9"], [null, null]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_2@tests.mozilla.org",
|
||||
name: "extension 2",
|
||||
version: "1.0",
|
||||
|
||||
// Should always be blocked
|
||||
blocklisted: [["1", "1.9"], [null, null]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_3a@tests.mozilla.org",
|
||||
name: "extension 3a",
|
||||
version: "1.0",
|
||||
|
||||
// Only version 1 should be blocked
|
||||
blocklisted: [["1", "1.9"], [null, null]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_3b@tests.mozilla.org",
|
||||
name: "extension 3b",
|
||||
version: "2.0",
|
||||
|
||||
// Only version 1 should be blocked
|
||||
notBlocklisted: [["1", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_4@tests.mozilla.org",
|
||||
name: "extension 4",
|
||||
version: "1.0",
|
||||
|
||||
// Should be blocked for app version 1
|
||||
blocklisted: [["1", "1.9"], [null, null]],
|
||||
notBlocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_5@tests.mozilla.org",
|
||||
name: "extension 5",
|
||||
version: "1.0",
|
||||
|
||||
// Not blocklisted because we are a different OS
|
||||
notBlocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_6@tests.mozilla.org",
|
||||
name: "extension 6",
|
||||
version: "1.0",
|
||||
|
||||
// Blocklisted based on OS
|
||||
blocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_7@tests.mozilla.org",
|
||||
name: "extension 7",
|
||||
version: "1.0",
|
||||
|
||||
// Blocklisted based on OS
|
||||
blocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_8@tests.mozilla.org",
|
||||
name: "extension 8",
|
||||
version: "1.0",
|
||||
|
||||
// Not blocklisted because we are a different ABI
|
||||
notBlocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_9@tests.mozilla.org",
|
||||
name: "extension 9",
|
||||
version: "1.0",
|
||||
|
||||
// Blocklisted based on ABI
|
||||
blocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_10@tests.mozilla.org",
|
||||
name: "extension 10",
|
||||
version: "1.0",
|
||||
|
||||
// Blocklisted based on ABI
|
||||
blocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_11@tests.mozilla.org",
|
||||
name: "extension 11",
|
||||
version: "1.0",
|
||||
|
||||
// Doesn't match both os and abi so not blocked
|
||||
notBlocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_12@tests.mozilla.org",
|
||||
name: "extension 12",
|
||||
version: "1.0",
|
||||
|
||||
// Doesn't match both os and abi so not blocked
|
||||
notBlocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_13@tests.mozilla.org",
|
||||
name: "extension 13",
|
||||
version: "1.0",
|
||||
|
||||
// Doesn't match both os and abi so not blocked
|
||||
notBlocklisted: [["2", "1.9"]],
|
||||
},
|
||||
{
|
||||
id: "test_bug393285_14@tests.mozilla.org",
|
||||
name: "extension 14",
|
||||
version: "1.0",
|
||||
|
||||
// Matches both os and abi so blocked
|
||||
blocklisted: [["2", "1.9"]],
|
||||
},
|
||||
];
|
||||
|
||||
const ADDON_IDS = ADDONS.map(a => a.id);
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
await promiseStartupManager();
|
||||
|
||||
for (let addon of ADDONS) {
|
||||
await promiseInstallWebExtension({
|
||||
manifest: {
|
||||
name: addon.name,
|
||||
version: addon.version,
|
||||
applications: {gecko: {id: addon.id}},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let addons = await getAddons(ADDON_IDS);
|
||||
for (let id of ADDON_IDS) {
|
||||
equal(addons.get(id).blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
|
||||
`Add-on ${id} should not initially be blocked`);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_1() {
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data"), "test_bug393285");
|
||||
|
||||
let addons = await getAddons(ADDON_IDS);
|
||||
async function isBlocklisted(addon, appVer, toolkitVer) {
|
||||
let state = await Blocklist.getAddonBlocklistState(addon, appVer, toolkitVer);
|
||||
return state != Services.blocklist.STATE_NOT_BLOCKED;
|
||||
}
|
||||
for (let addon of ADDONS) {
|
||||
let {id} = addon;
|
||||
for (let blocklisted of addon.blocklisted || []) {
|
||||
ok(await isBlocklisted(addons.get(id), ...blocklisted),
|
||||
`Add-on ${id} should be blocklisted in app/platform version ${blocklisted}`);
|
||||
}
|
||||
for (let notBlocklisted of addon.notBlocklisted || []) {
|
||||
ok(!(await isBlocklisted(addons.get(id), ...notBlocklisted)),
|
||||
`Add-on ${id} should not be blocklisted in app/platform version ${notBlocklisted}`);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -0,0 +1,34 @@
|
|||
/* 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 nsIBLS = Ci.nsIBlocklistService;
|
||||
|
||||
// Finds the test nsIPluginTag
|
||||
function get_test_plugintag() {
|
||||
var host = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
|
||||
var tags = host.getPluginTags();
|
||||
for (let tag of tags) {
|
||||
if (tag.name == "Test Plug-in")
|
||||
return tag;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
add_task(async function checkFlashOnlyPluginState() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
Services.prefs.setBoolPref("plugin.load_flash_only", false);
|
||||
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data"), "test_bug514327_2");
|
||||
|
||||
var plugin = get_test_plugintag();
|
||||
if (!plugin)
|
||||
do_throw("Plugin tag not found");
|
||||
|
||||
// run the code after the blocklist is closed
|
||||
Services.obs.notifyObservers(null, "addon-blocklist-closed");
|
||||
await new Promise(executeSoon);
|
||||
// should be marked as outdated by the blocklist
|
||||
Assert.equal(await Blocklist.getPluginBlocklistState(plugin, "1", "1.9"), nsIBLS.STATE_OUTDATED);
|
||||
});
|
|
@ -0,0 +1,88 @@
|
|||
/* 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 Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
|
||||
const nsIBLS = Ci.nsIBlocklistService;
|
||||
|
||||
var gBlocklist = null;
|
||||
|
||||
var PLUGINS = [{
|
||||
// Tests a plugin whose state goes from not-blocked, to outdated
|
||||
name: "test_bug514327_outdated",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
}, {
|
||||
// Used to trigger the blocklist dialog, which indicates the blocklist has updated
|
||||
name: "test_bug514327_1",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
}, {
|
||||
// Used to trigger the blocklist dialog, which indicates the blocklist has updated
|
||||
name: "test_bug514327_2",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
}].map(opts => new MockPluginTag(opts, opts.enabledState));
|
||||
|
||||
mockPluginHost(PLUGINS);
|
||||
|
||||
var BlocklistPrompt = {
|
||||
get wrappedJSObject() { return this; },
|
||||
|
||||
prompt(list) {
|
||||
// Should only include one item
|
||||
Assert.equal(list.length, 1);
|
||||
// And that item should be the blocked plugin, not the outdated one
|
||||
var item = list[0];
|
||||
Assert.ok(item.item instanceof Ci.nsIPluginTag);
|
||||
Assert.notEqual(item.name, "test_bug514327_outdated");
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([]),
|
||||
};
|
||||
|
||||
|
||||
let factory = XPCOMUtils.generateSingletonFactory(function() { return BlocklistPrompt; });
|
||||
Cm.registerFactory(Components.ID("{26d32654-30c7-485d-b983-b4d2568aebba}"),
|
||||
"Blocklist Prompt",
|
||||
"@mozilla.org/addons/blocklist-prompt;1", factory);
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
|
||||
await promiseStartupManager();
|
||||
// initialize the blocklist with no entries
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data/"), "test_bug514327_3_empty");
|
||||
|
||||
gBlocklist = Services.blocklist;
|
||||
|
||||
// The blocklist service defers plugin request until the Blocklist
|
||||
// module loads. Make sure it loads, or we'll wait forever.
|
||||
executeSoon(() => {
|
||||
void Blocklist;
|
||||
});
|
||||
|
||||
// should NOT be marked as outdated by the blocklist
|
||||
Assert.equal(await gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"), nsIBLS.STATE_NOT_BLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function test_part_1() {
|
||||
// update blocklist with data that marks the plugin as outdated
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data/"), "test_bug514327_3_outdated_1");
|
||||
|
||||
// plugin should now be marked as outdated
|
||||
Assert.equal(await gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"), nsIBLS.STATE_OUTDATED);
|
||||
});
|
||||
|
||||
add_task(async function test_part_2() {
|
||||
// update blocklist with data that marks the plugin as outdated
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data/"), "test_bug514327_3_outdated_2");
|
||||
|
||||
// plugin should still be marked as outdated
|
||||
Assert.equal(await gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"), nsIBLS.STATE_OUTDATED);
|
||||
});
|
|
@ -0,0 +1,60 @@
|
|||
/* 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/. */
|
||||
|
||||
var PLUGINS = [{
|
||||
// Normal blocklisted plugin, before an invalid regexp
|
||||
name: "test_bug468528_1",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// Normal blocklisted plugin, with an invalid regexp
|
||||
name: "test_bug468528_2",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// Normal blocklisted plugin, after an invalid regexp
|
||||
name: "test_bug468528_3",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// Non-blocklisted plugin
|
||||
name: "test_bug468528_4",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
}];
|
||||
|
||||
|
||||
add_task(async function checkBlocklistForRegexes() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
// We cannot force the blocklist to update so just copy our test list to the profile
|
||||
copyBlocklistToProfile(do_get_file("../data/test_bug468528.xml"));
|
||||
|
||||
var {blocklist} = Services;
|
||||
|
||||
// The blocklist service defers plugin request until the Blocklist
|
||||
// module loads. Make sure it loads, or we'll wait forever.
|
||||
executeSoon(() => {
|
||||
void Blocklist;
|
||||
});
|
||||
|
||||
// blocked (sanity check)
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"), blocklist.STATE_BLOCKED);
|
||||
|
||||
// not blocked - won't match due to invalid regexp
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[1], "1", "1.9"), blocklist.STATE_NOT_BLOCKED);
|
||||
|
||||
// blocked - the invalid regexp for the previous item shouldn't affect this one
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[2], "1", "1.9"), blocklist.STATE_BLOCKED);
|
||||
|
||||
// not blocked - the previous invalid regexp shouldn't act as a wildcard
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[3], "1", "1.9"), blocklist.STATE_NOT_BLOCKED);
|
||||
});
|
|
@ -0,0 +1,60 @@
|
|||
/* 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/. */
|
||||
|
||||
var PLUGINS = [{
|
||||
// blocklisted - default severity
|
||||
name: "test_bug514327_1",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// outdated - severity of "0"
|
||||
name: "test_bug514327_2",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// outdated - severity of "0"
|
||||
name: "test_bug514327_3",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// not blocklisted, not outdated
|
||||
name: "test_bug514327_4",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
outdated: false,
|
||||
}];
|
||||
|
||||
|
||||
add_task(async function checkBlocklistSeverities() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data/"), "test_bug514327_1");
|
||||
|
||||
var {blocklist} = Services;
|
||||
|
||||
// The blocklist service defers plugin request until the Blocklist
|
||||
// module loads. Make sure it loads, or we'll wait forever.
|
||||
executeSoon(() => {
|
||||
void Blocklist;
|
||||
});
|
||||
|
||||
// blocked (sanity check)
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"), blocklist.STATE_BLOCKED);
|
||||
|
||||
// outdated
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[1], "1", "1.9"), blocklist.STATE_OUTDATED);
|
||||
|
||||
// outdated
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[2], "1", "1.9"), blocklist.STATE_OUTDATED);
|
||||
|
||||
// not blocked
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[3], "1", "1.9"), blocklist.STATE_NOT_BLOCKED);
|
||||
});
|
|
@ -0,0 +1,65 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests resetting of preferences in blocklist entry when an add-on is blocked.
|
||||
// See bug 802434.
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
|
||||
|
||||
await promiseStartupManager();
|
||||
|
||||
// Add 2 extensions
|
||||
await promiseInstallWebExtension({
|
||||
manifest: {
|
||||
name: "Blocked add-on-1 with to-be-reset prefs",
|
||||
version: "1.0",
|
||||
applications: {gecko: {id: "block1@tests.mozilla.org"}},
|
||||
},
|
||||
});
|
||||
await promiseInstallWebExtension({
|
||||
manifest: {
|
||||
name: "Blocked add-on-2 with to-be-reset prefs",
|
||||
version: "1.0",
|
||||
applications: {gecko: {id: "block2@tests.mozilla.org"}},
|
||||
},
|
||||
});
|
||||
|
||||
// Pre-set the preferences that we expect to get reset.
|
||||
Services.prefs.setIntPref("test.blocklist.pref1", 15);
|
||||
Services.prefs.setIntPref("test.blocklist.pref2", 15);
|
||||
Services.prefs.setBoolPref("test.blocklist.pref3", true);
|
||||
Services.prefs.setBoolPref("test.blocklist.pref4", true);
|
||||
|
||||
|
||||
// Before blocklist is loaded.
|
||||
let [a1, a2] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
|
||||
"block2@tests.mozilla.org"]);
|
||||
Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
Assert.equal(Services.prefs.getIntPref("test.blocklist.pref1"), 15);
|
||||
Assert.equal(Services.prefs.getIntPref("test.blocklist.pref2"), 15);
|
||||
Assert.equal(Services.prefs.getBoolPref("test.blocklist.pref3"), true);
|
||||
Assert.equal(Services.prefs.getBoolPref("test.blocklist.pref4"), true);
|
||||
});
|
||||
|
||||
|
||||
add_task(async function test_blocks() {
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data/"), "test_blocklist_prefs_1");
|
||||
|
||||
// Blocklist changes should have applied and the prefs must be reset.
|
||||
let [a1, a2] = await AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
|
||||
"block2@tests.mozilla.org"]);
|
||||
Assert.notEqual(a1, null);
|
||||
Assert.equal(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
Assert.notEqual(a2, null);
|
||||
Assert.equal(a2.blocklistState, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
// All these prefs must be reset to defaults.
|
||||
Assert.equal(Services.prefs.prefHasUserValue("test.blocklist.pref1"), false);
|
||||
Assert.equal(Services.prefs.prefHasUserValue("test.blocklist.pref2"), false);
|
||||
Assert.equal(Services.prefs.prefHasUserValue("test.blocklist.pref3"), false);
|
||||
Assert.equal(Services.prefs.prefHasUserValue("test.blocklist.pref4"), false);
|
||||
});
|
|
@ -0,0 +1,396 @@
|
|||
/* 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 URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
|
||||
|
||||
// Workaround for Bug 658720 - URL formatter can leak during xpcshell tests
|
||||
const PREF_BLOCKLIST_ITEM_URL = "extensions.blocklist.itemURL";
|
||||
Services.prefs.setCharPref(PREF_BLOCKLIST_ITEM_URL, "http://example.com/blocklist/%blockID%");
|
||||
|
||||
async function getAddonBlocklistURL(addon) {
|
||||
let entry = await Blocklist.getAddonBlocklistEntry(addon);
|
||||
return entry && entry.url;
|
||||
}
|
||||
|
||||
var ADDONS = [{
|
||||
// Tests how the blocklist affects a disabled add-on
|
||||
id: "test_bug455906_1@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 1",
|
||||
version: "5",
|
||||
appVersion: "3",
|
||||
}, {
|
||||
// Tests how the blocklist affects an enabled add-on
|
||||
id: "test_bug455906_2@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 2",
|
||||
version: "5",
|
||||
appVersion: "3",
|
||||
}, {
|
||||
// Tests how the blocklist affects an enabled add-on, to be disabled by the notification
|
||||
id: "test_bug455906_3@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 3",
|
||||
version: "5",
|
||||
appVersion: "3",
|
||||
}, {
|
||||
// Tests how the blocklist affects a disabled add-on that was already warned about
|
||||
id: "test_bug455906_4@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 4",
|
||||
version: "5",
|
||||
appVersion: "3",
|
||||
}, {
|
||||
// Tests how the blocklist affects an enabled add-on that was already warned about
|
||||
id: "test_bug455906_5@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 5",
|
||||
version: "5",
|
||||
appVersion: "3",
|
||||
}, {
|
||||
// Tests how the blocklist affects an already blocked add-on
|
||||
id: "test_bug455906_6@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 6",
|
||||
version: "5",
|
||||
appVersion: "3",
|
||||
}, {
|
||||
// Tests how the blocklist affects an incompatible add-on
|
||||
id: "test_bug455906_7@tests.mozilla.org",
|
||||
name: "Bug 455906 Addon Test 7",
|
||||
version: "5",
|
||||
appVersion: "2",
|
||||
}, {
|
||||
// Spare add-on used to ensure we get a notification when switching lists
|
||||
id: "dummy_bug455906_1@tests.mozilla.org",
|
||||
name: "Dummy Addon 1",
|
||||
version: "5",
|
||||
appVersion: "3",
|
||||
}, {
|
||||
// Spare add-on used to ensure we get a notification when switching lists
|
||||
id: "dummy_bug455906_2@tests.mozilla.org",
|
||||
name: "Dummy Addon 2",
|
||||
version: "5",
|
||||
appVersion: "3",
|
||||
}];
|
||||
|
||||
var PLUGINS = [
|
||||
// Tests how the blocklist affects a disabled plugin
|
||||
new MockPluginTag({name: "test_bug455906_1", version: "5"}, Ci.nsIPluginTag.STATE_DISABLED),
|
||||
// Tests how the blocklist affects an enabled plugin
|
||||
new MockPluginTag({name: "test_bug455906_2", version: "5"}, Ci.nsIPluginTag.STATE_ENABLED),
|
||||
// Tests how the blocklist affects an enabled plugin, to be disabled by the notification
|
||||
new MockPluginTag({name: "test_bug455906_3", version: "5"}, Ci.nsIPluginTag.STATE_ENABLED),
|
||||
// Tests how the blocklist affects a disabled plugin that was already warned about
|
||||
new MockPluginTag({name: "test_bug455906_4", version: "5"}, Ci.nsIPluginTag.STATE_DISABLED),
|
||||
// Tests how the blocklist affects an enabled plugin that was already warned about
|
||||
new MockPluginTag({name: "test_bug455906_5", version: "5"}, Ci.nsIPluginTag.STATE_ENABLED),
|
||||
// Tests how the blocklist affects an already blocked plugin
|
||||
new MockPluginTag({name: "test_bug455906_6", version: "5"}, Ci.nsIPluginTag.STATE_ENABLED),
|
||||
];
|
||||
|
||||
var gNotificationCheck = null;
|
||||
|
||||
// Don't need the full interface, attempts to call other methods will just
|
||||
// throw which is just fine
|
||||
var WindowWatcher = {
|
||||
openWindow(parent, url, name, features, windowArguments) {
|
||||
// Should be called to list the newly blocklisted items
|
||||
equal(url, URI_EXTENSION_BLOCKLIST_DIALOG);
|
||||
|
||||
if (gNotificationCheck) {
|
||||
gNotificationCheck(windowArguments.wrappedJSObject);
|
||||
}
|
||||
|
||||
// run the code after the blocklist is closed
|
||||
Services.obs.notifyObservers(null, "addon-blocklist-closed");
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIWindowWatcher"]),
|
||||
};
|
||||
|
||||
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
|
||||
|
||||
function createAddon(addon) {
|
||||
return promiseInstallWebExtension({
|
||||
manifest: {
|
||||
name: addon.name,
|
||||
version: addon.version,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: addon.id,
|
||||
strict_min_version: addon.appVersion,
|
||||
strict_max_version: addon.appVersion,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function loadBlocklist(file, callback) {
|
||||
gNotificationCheck = callback;
|
||||
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data"), file);
|
||||
}
|
||||
|
||||
async function check_plugin_state(plugin) {
|
||||
let blocklistState = await Blocklist.getPluginBlocklistState(plugin);
|
||||
return `${plugin.disabled},${blocklistState == Services.blocklist.STATE_BLOCKED}`;
|
||||
}
|
||||
|
||||
function create_blocklistURL(blockID) {
|
||||
let url = Services.urlFormatter.formatURLPref(PREF_BLOCKLIST_ITEM_URL);
|
||||
url = url.replace(/%blockID%/g, blockID);
|
||||
return url;
|
||||
}
|
||||
|
||||
// Before every main test this is the state the add-ons are meant to be in
|
||||
async function checkInitialState() {
|
||||
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
|
||||
|
||||
checkAddonState(addons[0], {userDisabled: true, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[1], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[2], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[3], {userDisabled: true, softDisabled: true, appDisabled: false});
|
||||
checkAddonState(addons[4], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[5], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
checkAddonState(addons[6], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
|
||||
equal(await check_plugin_state(PLUGINS[0]), "true,false");
|
||||
equal(await check_plugin_state(PLUGINS[1]), "false,false");
|
||||
equal(await check_plugin_state(PLUGINS[2]), "false,false");
|
||||
equal(await check_plugin_state(PLUGINS[3]), "true,false");
|
||||
equal(await check_plugin_state(PLUGINS[4]), "false,false");
|
||||
equal(await check_plugin_state(PLUGINS[5]), "false,true");
|
||||
}
|
||||
|
||||
function checkAddonState(addon, state) {
|
||||
return checkAddon(addon.id, addon, state);
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "3");
|
||||
|
||||
await promiseStartupManager();
|
||||
|
||||
// Load the initial blocklist into the profile to check add-ons start in the
|
||||
// right state.
|
||||
// Make sure to do this before we touch the plugin service, since that
|
||||
// will force a blocklist load.
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data/"), "bug455906_start");
|
||||
mockPluginHost(PLUGINS);
|
||||
|
||||
|
||||
for (let addon of ADDONS)
|
||||
await createAddon(addon);
|
||||
});
|
||||
|
||||
add_task(async function test_1() {
|
||||
// Tests the add-ons were installed and the initial blocklist applied as expected
|
||||
|
||||
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
|
||||
for (var i = 0; i < ADDONS.length; i++) {
|
||||
ok(addons[i], `Addon ${i + 1} should be installed correctly`);
|
||||
}
|
||||
|
||||
checkAddonState(addons[0], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[1], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[2], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
|
||||
// Warn add-ons should be soft disabled automatically
|
||||
checkAddonState(addons[3], {userDisabled: true, softDisabled: true, appDisabled: false});
|
||||
checkAddonState(addons[4], {userDisabled: true, softDisabled: true, appDisabled: false});
|
||||
|
||||
// Blocked and incompatible should be app disabled only
|
||||
checkAddonState(addons[5], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
checkAddonState(addons[6], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
|
||||
// We've overridden the plugin host so we cannot tell what that would have
|
||||
// initialised the plugins as
|
||||
|
||||
// Put the add-ons into the base state
|
||||
await addons[0].disable();
|
||||
await addons[4].enable();
|
||||
|
||||
await promiseRestartManager();
|
||||
await checkInitialState();
|
||||
|
||||
await loadBlocklist("bug455906_warn", args => {
|
||||
dump("Checking notification pt 2\n");
|
||||
// Note: in the XML version, this notifies for 4 items - 2 add-ons and 2 plugins.
|
||||
// This test is artificial, we don't notify for add-ons anymore, see
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1257565#c111 . Cleaning this up
|
||||
// should happen but this patchset is too huge as it is so I'm deferring it.
|
||||
equal(args.list.length, 2);
|
||||
|
||||
for (let addon of args.list) {
|
||||
if (addon.item instanceof Ci.nsIPluginTag) {
|
||||
switch (addon.item.name) {
|
||||
case "test_bug455906_2":
|
||||
ok(!addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_3":
|
||||
ok(!addon.blocked);
|
||||
addon.disable = true;
|
||||
break;
|
||||
default:
|
||||
do_throw("Unknown plugin: " + addon.item.name);
|
||||
}
|
||||
} else {
|
||||
do_throw("Everything here should be a plugin, what is this?!");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await promiseRestartManager();
|
||||
dump("Checking results pt 2\n");
|
||||
|
||||
addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
|
||||
|
||||
info("Should have disabled this add-on as requested");
|
||||
checkAddonState(addons[2], {userDisabled: true, softDisabled: true, appDisabled: false});
|
||||
equal(await check_plugin_state(PLUGINS[2]), "true,false");
|
||||
|
||||
info("The blocked add-on should have changed to soft disabled");
|
||||
checkAddonState(addons[5], {userDisabled: true, softDisabled: true, appDisabled: false});
|
||||
checkAddonState(addons[6], {userDisabled: true, softDisabled: true, appDisabled: true});
|
||||
equal(await check_plugin_state(PLUGINS[5]), "true,false");
|
||||
|
||||
info("These should have been unchanged");
|
||||
checkAddonState(addons[0], {userDisabled: true, softDisabled: false, appDisabled: false});
|
||||
// XXXgijs this is supposed to be not user disabled or soft disabled, but because we don't show
|
||||
// the dialog, it's disabled anyway. Comment out this assertion for now...
|
||||
// checkAddonState(addons[1], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[3], {userDisabled: true, softDisabled: true, appDisabled: false});
|
||||
checkAddonState(addons[4], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
equal(await check_plugin_state(PLUGINS[0]), "true,false");
|
||||
equal(await check_plugin_state(PLUGINS[1]), "false,false");
|
||||
equal(await check_plugin_state(PLUGINS[3]), "true,false");
|
||||
equal(await check_plugin_state(PLUGINS[4]), "false,false");
|
||||
|
||||
// Back to starting state
|
||||
await addons[2].enable();
|
||||
await addons[5].enable();
|
||||
PLUGINS[2].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
|
||||
PLUGINS[5].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
|
||||
|
||||
await promiseRestartManager();
|
||||
await loadBlocklist("bug455906_start");
|
||||
});
|
||||
|
||||
add_task(async function test_pt3() {
|
||||
await promiseRestartManager();
|
||||
await checkInitialState();
|
||||
|
||||
await loadBlocklist("bug455906_block", args => {
|
||||
dump("Checking notification pt 3\n");
|
||||
equal(args.list.length, 3);
|
||||
|
||||
for (let addon of args.list) {
|
||||
if (addon.item instanceof Ci.nsIPluginTag) {
|
||||
switch (addon.item.name) {
|
||||
case "test_bug455906_2":
|
||||
ok(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_3":
|
||||
ok(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_5":
|
||||
ok(addon.blocked);
|
||||
break;
|
||||
default:
|
||||
do_throw("Unknown addon: " + addon.item.name);
|
||||
}
|
||||
} else {
|
||||
switch (addon.item.id) {
|
||||
case "test_bug455906_2@tests.mozilla.org":
|
||||
ok(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_3@tests.mozilla.org":
|
||||
ok(addon.blocked);
|
||||
break;
|
||||
case "test_bug455906_5@tests.mozilla.org":
|
||||
ok(addon.blocked);
|
||||
break;
|
||||
default:
|
||||
do_throw("Unknown addon: " + addon.item.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await promiseRestartManager();
|
||||
dump("Checking results pt 3\n");
|
||||
|
||||
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
|
||||
|
||||
// All should have gained the blocklist state, user disabled as previously
|
||||
checkAddonState(addons[0], {userDisabled: true, softDisabled: false, appDisabled: true});
|
||||
checkAddonState(addons[1], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
checkAddonState(addons[2], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
checkAddonState(addons[4], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
equal(await check_plugin_state(PLUGINS[0]), "true,true");
|
||||
equal(await check_plugin_state(PLUGINS[1]), "false,true");
|
||||
equal(await check_plugin_state(PLUGINS[2]), "false,true");
|
||||
equal(await check_plugin_state(PLUGINS[3]), "true,true");
|
||||
equal(await check_plugin_state(PLUGINS[4]), "false,true");
|
||||
|
||||
// Should have gained the blocklist state but no longer be soft disabled
|
||||
checkAddonState(addons[3], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
|
||||
// Check blockIDs are correct
|
||||
equal(await getAddonBlocklistURL(addons[0]), create_blocklistURL(addons[0].id));
|
||||
equal(await getAddonBlocklistURL(addons[1]), create_blocklistURL(addons[1].id));
|
||||
equal(await getAddonBlocklistURL(addons[2]), create_blocklistURL(addons[2].id));
|
||||
equal(await getAddonBlocklistURL(addons[3]), create_blocklistURL(addons[3].id));
|
||||
equal(await getAddonBlocklistURL(addons[4]), create_blocklistURL(addons[4].id));
|
||||
|
||||
// All plugins have the same blockID on the test
|
||||
equal(await Blocklist.getPluginBlockURL(PLUGINS[0]), create_blocklistURL("test_bug455906_plugin"));
|
||||
equal(await Blocklist.getPluginBlockURL(PLUGINS[1]), create_blocklistURL("test_bug455906_plugin"));
|
||||
equal(await Blocklist.getPluginBlockURL(PLUGINS[2]), create_blocklistURL("test_bug455906_plugin"));
|
||||
equal(await Blocklist.getPluginBlockURL(PLUGINS[3]), create_blocklistURL("test_bug455906_plugin"));
|
||||
equal(await Blocklist.getPluginBlockURL(PLUGINS[4]), create_blocklistURL("test_bug455906_plugin"));
|
||||
|
||||
// Shouldn't be changed
|
||||
checkAddonState(addons[5], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
checkAddonState(addons[6], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
equal(await check_plugin_state(PLUGINS[5]), "false,true");
|
||||
|
||||
// Back to starting state
|
||||
await loadBlocklist("bug455906_start");
|
||||
});
|
||||
|
||||
add_task(async function test_pt4() {
|
||||
let addon = await AddonManager.getAddonByID(ADDONS[4].id);
|
||||
await addon.enable();
|
||||
PLUGINS[4].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
|
||||
|
||||
await promiseRestartManager();
|
||||
await checkInitialState();
|
||||
|
||||
await loadBlocklist("bug455906_empty", args => {
|
||||
dump("Checking notification pt 4\n");
|
||||
// See note in other callback - we no longer notify for non-blocked add-ons.
|
||||
ok(false, "Should not get a notification as there are no blocked plugins.");
|
||||
});
|
||||
|
||||
await promiseRestartManager();
|
||||
dump("Checking results pt 4\n");
|
||||
|
||||
let addons = await AddonManager.getAddonsByIDs(ADDONS.map(a => a.id));
|
||||
// This should have become unblocked
|
||||
checkAddonState(addons[5], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
equal(await check_plugin_state(PLUGINS[5]), "false,false");
|
||||
|
||||
// Should get re-enabled
|
||||
checkAddonState(addons[3], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
|
||||
// No change for anything else
|
||||
checkAddonState(addons[0], {userDisabled: true, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[1], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[2], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[4], {userDisabled: false, softDisabled: false, appDisabled: false});
|
||||
checkAddonState(addons[6], {userDisabled: false, softDisabled: false, appDisabled: true});
|
||||
equal(await check_plugin_state(PLUGINS[0]), "true,false");
|
||||
equal(await check_plugin_state(PLUGINS[1]), "false,false");
|
||||
equal(await check_plugin_state(PLUGINS[2]), "false,false");
|
||||
equal(await check_plugin_state(PLUGINS[3]), "true,false");
|
||||
equal(await check_plugin_state(PLUGINS[4]), "false,false");
|
||||
});
|
|
@ -0,0 +1,750 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Checks that changes that cause an add-on to become unblocked or blocked have
|
||||
// the right effect
|
||||
|
||||
// The tests follow a mostly common pattern. First they start with the add-ons
|
||||
// unblocked, then they make a change that causes the add-ons to become blocked
|
||||
// then they make a similar change that keeps the add-ons blocked then they make
|
||||
// a change that unblocks the add-ons. Some tests skip the initial part and
|
||||
// start with add-ons detected as blocked.
|
||||
|
||||
// softblock1 is enabled/disabled by the blocklist changes so its softDisabled
|
||||
// property should always match its userDisabled property
|
||||
|
||||
// softblock2 gets manually enabled then disabled after it becomes blocked so
|
||||
// its softDisabled property should never become true after that
|
||||
|
||||
// softblock3 does the same as softblock2 however it remains disabled
|
||||
|
||||
// softblock4 is disabled while unblocked and so should never have softDisabled
|
||||
// set to true and stay userDisabled. This add-on is not used in tests that
|
||||
// start with add-ons blocked as it would be identical to softblock3
|
||||
|
||||
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
|
||||
|
||||
// Allow insecure updates
|
||||
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
|
||||
|
||||
Services.prefs.setBoolPref("extensions.webextPermissionPrompts", false);
|
||||
|
||||
var testserver = createHttpServer({hosts: ["example.com"]});
|
||||
// Needed for updates:
|
||||
testserver.registerDirectory("/data/", do_get_file("../data"));
|
||||
|
||||
const XPIS = {};
|
||||
|
||||
const ADDON_IDS = ["softblock1@tests.mozilla.org",
|
||||
"softblock2@tests.mozilla.org",
|
||||
"softblock3@tests.mozilla.org",
|
||||
"softblock4@tests.mozilla.org",
|
||||
"hardblock@tests.mozilla.org",
|
||||
"regexpblock@tests.mozilla.org"];
|
||||
|
||||
// XXXgijs: according to https://bugzilla.mozilla.org/show_bug.cgi?id=1257565#c111
|
||||
// this code and the related code in Blocklist.jsm (specific to XML blocklist) is
|
||||
// dead code and can be removed. See https://bugzilla.mozilla.org/show_bug.cgi?id=1549550 .
|
||||
//
|
||||
// Don't need the full interface, attempts to call other methods will just
|
||||
// throw which is just fine
|
||||
var WindowWatcher = {
|
||||
openWindow(parent, url, name, features, openArgs) {
|
||||
// Should be called to list the newly blocklisted items
|
||||
Assert.equal(url, URI_EXTENSION_BLOCKLIST_DIALOG);
|
||||
|
||||
// Simulate auto-disabling any softblocks
|
||||
var list = openArgs.wrappedJSObject.list;
|
||||
list.forEach(function(aItem) {
|
||||
if (!aItem.blocked)
|
||||
aItem.disable = true;
|
||||
});
|
||||
|
||||
// run the code after the blocklist is closed
|
||||
Services.obs.notifyObservers(null, "addon-blocklist-closed");
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIWindowWatcher"]),
|
||||
};
|
||||
|
||||
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
|
||||
|
||||
var InstallConfirm = {
|
||||
confirm(aWindow, aUrl, aInstalls, aInstallCount) {
|
||||
aInstalls.forEach(function(aInstall) {
|
||||
aInstall.install();
|
||||
});
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI(["amIWebInstallPrompt"]),
|
||||
};
|
||||
|
||||
var InstallConfirmFactory = {
|
||||
createInstance: function createInstance(outer, iid) {
|
||||
if (outer != null)
|
||||
throw Cr.NS_ERROR_NO_AGGREGATION;
|
||||
return InstallConfirm.QueryInterface(iid);
|
||||
},
|
||||
};
|
||||
|
||||
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
registrar.registerFactory(Components.ID("{f0863905-4dde-42e2-991c-2dc8209bc9ca}"),
|
||||
"Fake Install Prompt",
|
||||
"@mozilla.org/addons/web-install-prompt;1", InstallConfirmFactory);
|
||||
|
||||
function Pload_blocklist(aFile) {
|
||||
return AddonTestUtils.loadBlocklistData(do_get_file("../data/blocklistchange/"), aFile);
|
||||
}
|
||||
|
||||
// Does a background update check for add-ons and returns a promise that
|
||||
// resolves when any started installs complete
|
||||
function Pbackground_update() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let installCount = 0;
|
||||
let backgroundCheckCompleted = false;
|
||||
|
||||
AddonManager.addInstallListener({
|
||||
onNewInstall(aInstall) {
|
||||
installCount++;
|
||||
},
|
||||
|
||||
onInstallEnded(aInstall) {
|
||||
installCount--;
|
||||
// Wait until all started installs have completed
|
||||
if (installCount)
|
||||
return;
|
||||
|
||||
AddonManager.removeInstallListener(this);
|
||||
|
||||
// If the background check hasn't yet completed then let that call the
|
||||
// callback when it is done
|
||||
if (!backgroundCheckCompleted)
|
||||
return;
|
||||
|
||||
resolve();
|
||||
},
|
||||
});
|
||||
|
||||
Services.obs.addObserver(function observer() {
|
||||
Services.obs.removeObserver(observer, "addons-background-update-complete");
|
||||
backgroundCheckCompleted = true;
|
||||
|
||||
// If any new installs have started then we'll call the callback once they
|
||||
// are completed
|
||||
if (installCount)
|
||||
return;
|
||||
|
||||
resolve();
|
||||
}, "addons-background-update-complete");
|
||||
|
||||
AddonManagerPrivate.backgroundUpdateCheck();
|
||||
});
|
||||
}
|
||||
|
||||
// Manually updates the test add-ons to the given version
|
||||
function Pmanual_update(aVersion) {
|
||||
const names = ["soft1", "soft2", "soft3", "soft4", "hard", "regexp"];
|
||||
return Promise.all(names.map(async name => {
|
||||
let url = `http://example.com/addons/blocklist_${name}_${aVersion}.xpi`;
|
||||
let install = await AddonManager.getInstallForURL(url);
|
||||
|
||||
// installAddonFromAOM() does more checking than install.install().
|
||||
// In particular, it will refuse to install an incompatible addon.
|
||||
|
||||
return new Promise(resolve => {
|
||||
install.addListener({
|
||||
onDownloadCancelled: resolve,
|
||||
onInstallEnded: resolve,
|
||||
});
|
||||
|
||||
AddonManager.installAddonFromAOM(null, null, install);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
// Checks that an add-ons properties match expected values
|
||||
function check_addon(aAddon, aExpectedVersion, aExpectedUserDisabled,
|
||||
aExpectedSoftDisabled, aExpectedState) {
|
||||
Assert.notEqual(aAddon, null);
|
||||
info("Testing " + aAddon.id + " version " + aAddon.version + " user "
|
||||
+ aAddon.userDisabled + " soft " + aAddon.softDisabled
|
||||
+ " perms " + aAddon.permissions);
|
||||
|
||||
Assert.equal(aAddon.version, aExpectedVersion);
|
||||
Assert.equal(aAddon.blocklistState, aExpectedState);
|
||||
Assert.equal(aAddon.userDisabled, aExpectedUserDisabled);
|
||||
Assert.equal(aAddon.softDisabled, aExpectedSoftDisabled);
|
||||
if (aAddon.softDisabled)
|
||||
Assert.ok(aAddon.userDisabled);
|
||||
|
||||
if (aExpectedState == Ci.nsIBlocklistService.STATE_BLOCKED) {
|
||||
info("blocked, PERM_CAN_ENABLE " + aAddon.id);
|
||||
Assert.ok(!hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
info("blocked, PERM_CAN_DISABLE " + aAddon.id);
|
||||
Assert.ok(!hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
} else if (aAddon.userDisabled) {
|
||||
info("userDisabled, PERM_CAN_ENABLE " + aAddon.id);
|
||||
Assert.ok(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
info("userDisabled, PERM_CAN_DISABLE " + aAddon.id);
|
||||
Assert.ok(!hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
} else {
|
||||
info("other, PERM_CAN_ENABLE " + aAddon.id);
|
||||
Assert.ok(!hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE));
|
||||
if (aAddon.type != "theme") {
|
||||
info("other, PERM_CAN_DISABLE " + aAddon.id);
|
||||
Assert.ok(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE));
|
||||
}
|
||||
}
|
||||
Assert.equal(aAddon.appDisabled, aExpectedState == Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
let willBeActive = aAddon.isActive;
|
||||
if (hasFlag(aAddon.pendingOperations, AddonManager.PENDING_DISABLE))
|
||||
willBeActive = false;
|
||||
else if (hasFlag(aAddon.pendingOperations, AddonManager.PENDING_ENABLE))
|
||||
willBeActive = true;
|
||||
|
||||
if (aExpectedUserDisabled || aExpectedState == Ci.nsIBlocklistService.STATE_BLOCKED) {
|
||||
Assert.ok(!willBeActive);
|
||||
} else {
|
||||
Assert.ok(willBeActive);
|
||||
}
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
|
||||
|
||||
// pattern used to map ids like softblock1 to soft1
|
||||
let pattern = /^(soft|hard|regexp)block([1-9]*)@/;
|
||||
for (let id of ADDON_IDS) {
|
||||
for (let version of [1, 2, 3]) {
|
||||
let match = id.match(pattern);
|
||||
let name = `blocklist_${match[1]}${match[2]}_${version}`;
|
||||
|
||||
XPIS[name] = createTempWebExtensionFile({
|
||||
manifest: {
|
||||
name: "Test",
|
||||
version: `${version}.0`,
|
||||
applications: {
|
||||
gecko: {
|
||||
id,
|
||||
update_url: `http://example.com/data/blocklistchange/addon_update${version}.json`,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
testserver.registerFile(`/addons/${name}.xpi`, XPIS[name]);
|
||||
}
|
||||
}
|
||||
|
||||
await promiseStartupManager();
|
||||
|
||||
await promiseInstallFile(XPIS.blocklist_soft1_1);
|
||||
await promiseInstallFile(XPIS.blocklist_soft2_1);
|
||||
await promiseInstallFile(XPIS.blocklist_soft3_1);
|
||||
await promiseInstallFile(XPIS.blocklist_soft4_1);
|
||||
await promiseInstallFile(XPIS.blocklist_hard_1);
|
||||
await promiseInstallFile(XPIS.blocklist_regexp_1);
|
||||
|
||||
let s4 = await promiseAddonByID("softblock4@tests.mozilla.org");
|
||||
await s4.disable();
|
||||
});
|
||||
|
||||
// Starts with add-ons unblocked and then switches application versions to
|
||||
// change add-ons to blocked and back
|
||||
add_task(async function run_app_update_test() {
|
||||
await Pload_blocklist("app_update");
|
||||
await promiseRestartManager();
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function app_update_step_2() {
|
||||
await promiseRestartManager("2");
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
await s2.enable();
|
||||
await s2.disable();
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
await s3.enable();
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function app_update_step_3() {
|
||||
await promiseRestartManager();
|
||||
|
||||
await promiseRestartManager("2.5");
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function app_update_step_4() {
|
||||
await promiseRestartManager("1");
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
await s1.enable();
|
||||
await s2.enable();
|
||||
});
|
||||
|
||||
// Starts with add-ons unblocked and then switches application versions to
|
||||
// change add-ons to blocked and back. A DB schema change is faked to force a
|
||||
// rebuild when the application version changes
|
||||
add_task(async function run_app_update_schema_test() {
|
||||
await promiseRestartManager();
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function update_schema_2() {
|
||||
await promiseShutdownManager();
|
||||
|
||||
await changeXPIDBVersion(100);
|
||||
gAppInfo.version = "2";
|
||||
let bsPassBlocklist = ChromeUtils.import("resource://gre/modules/Blocklist.jsm", null);
|
||||
Object.defineProperty(bsPassBlocklist, "gAppVersion", {value: "2"});
|
||||
await promiseStartupManager();
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
await s2.enable();
|
||||
await s2.disable();
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
await s3.enable();
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function update_schema_3() {
|
||||
await promiseRestartManager();
|
||||
|
||||
await promiseShutdownManager();
|
||||
await changeXPIDBVersion(100);
|
||||
gAppInfo.version = "2.5";
|
||||
let bsPassBlocklist = ChromeUtils.import("resource://gre/modules/Blocklist.jsm", null);
|
||||
Object.defineProperty(bsPassBlocklist, "gAppVersion", {value: "2.5"});
|
||||
await promiseStartupManager();
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function update_schema_4() {
|
||||
await promiseShutdownManager();
|
||||
|
||||
await changeXPIDBVersion(100);
|
||||
await promiseStartupManager();
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function update_schema_5() {
|
||||
await promiseShutdownManager();
|
||||
|
||||
await changeXPIDBVersion(100);
|
||||
gAppInfo.version = "1";
|
||||
let bsPassBlocklist = ChromeUtils.import("resource://gre/modules/Blocklist.jsm", null);
|
||||
Object.defineProperty(bsPassBlocklist, "gAppVersion", {value: "1"});
|
||||
await promiseStartupManager();
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
await s1.enable();
|
||||
await s2.enable();
|
||||
});
|
||||
|
||||
// Starts with add-ons unblocked and then loads new blocklists to change add-ons
|
||||
// to blocked and back again.
|
||||
add_task(async function run_blocklist_update_test() {
|
||||
await Pload_blocklist("blocklist_update1");
|
||||
await promiseRestartManager();
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
await Pload_blocklist("blocklist_update2");
|
||||
await promiseRestartManager();
|
||||
|
||||
[s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
await s2.enable();
|
||||
await s2.disable();
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
await s3.enable();
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
|
||||
await promiseRestartManager();
|
||||
|
||||
await Pload_blocklist("blocklist_update2");
|
||||
await promiseRestartManager();
|
||||
|
||||
[s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
await Pload_blocklist("blocklist_update1");
|
||||
await promiseRestartManager();
|
||||
|
||||
[s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
await s1.enable();
|
||||
await s2.enable();
|
||||
});
|
||||
|
||||
// Starts with add-ons unblocked and then new versions are installed outside of
|
||||
// the app to change them to blocked and back again.
|
||||
add_task(async function run_addon_change_test() {
|
||||
await Pload_blocklist("addon_change");
|
||||
await promiseRestartManager();
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function run_addon_change_2() {
|
||||
await promiseInstallFile(XPIS.blocklist_soft1_2);
|
||||
await promiseInstallFile(XPIS.blocklist_soft2_2);
|
||||
await promiseInstallFile(XPIS.blocklist_soft3_2);
|
||||
await promiseInstallFile(XPIS.blocklist_soft4_2);
|
||||
await promiseInstallFile(XPIS.blocklist_hard_2);
|
||||
await promiseInstallFile(XPIS.blocklist_regexp_2);
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
await s2.enable();
|
||||
await s2.disable();
|
||||
check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
await s3.enable();
|
||||
check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function run_addon_change_3() {
|
||||
await promiseInstallFile(XPIS.blocklist_soft1_3);
|
||||
await promiseInstallFile(XPIS.blocklist_soft2_3);
|
||||
await promiseInstallFile(XPIS.blocklist_soft3_3);
|
||||
await promiseInstallFile(XPIS.blocklist_soft4_3);
|
||||
await promiseInstallFile(XPIS.blocklist_hard_3);
|
||||
await promiseInstallFile(XPIS.blocklist_regexp_3);
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
});
|
||||
|
||||
add_task(async function run_addon_change_4() {
|
||||
await promiseInstallFile(XPIS.blocklist_soft1_1);
|
||||
await promiseInstallFile(XPIS.blocklist_soft2_1);
|
||||
await promiseInstallFile(XPIS.blocklist_soft3_1);
|
||||
await promiseInstallFile(XPIS.blocklist_soft4_1);
|
||||
await promiseInstallFile(XPIS.blocklist_hard_1);
|
||||
await promiseInstallFile(XPIS.blocklist_regexp_1);
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
await s1.enable();
|
||||
await s2.enable();
|
||||
});
|
||||
|
||||
// Add-ons are initially unblocked then attempts to upgrade to blocked versions
|
||||
// in the background which should fail
|
||||
add_task(async function run_background_update_test() {
|
||||
await promiseRestartManager();
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
await Pbackground_update();
|
||||
await promiseRestartManager();
|
||||
|
||||
[s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
});
|
||||
|
||||
// Starts with add-ons blocked and then new versions are detected and installed
|
||||
// automatically for unblocked versions.
|
||||
add_task(async function run_background_update_2_test() {
|
||||
await promiseInstallFile(XPIS.blocklist_soft1_3);
|
||||
await promiseInstallFile(XPIS.blocklist_soft2_3);
|
||||
await promiseInstallFile(XPIS.blocklist_soft3_3);
|
||||
await promiseInstallFile(XPIS.blocklist_soft4_3);
|
||||
await promiseInstallFile(XPIS.blocklist_hard_3);
|
||||
await promiseInstallFile(XPIS.blocklist_regexp_3);
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
await s2.enable();
|
||||
await s2.disable();
|
||||
check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
await s3.enable();
|
||||
check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
|
||||
await Pbackground_update();
|
||||
|
||||
[s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
await s1.enable();
|
||||
await s2.enable();
|
||||
await s4.disable();
|
||||
});
|
||||
|
||||
// Starts with add-ons blocked and then simulates the user upgrading them to
|
||||
// unblocked versions.
|
||||
add_task(async function run_manual_update_test() {
|
||||
await Pload_blocklist("manual_update");
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
await s2.enable();
|
||||
await s2.disable();
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
await s3.enable();
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
|
||||
await Pmanual_update("2");
|
||||
|
||||
[s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s4, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
// Can't manually update to a hardblocked add-on
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
await Pmanual_update("3");
|
||||
|
||||
[s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s4, "3.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
});
|
||||
|
||||
// Starts with add-ons blocked and then new versions are installed outside of
|
||||
// the app to change them to unblocked.
|
||||
add_task(async function run_manual_update_2_test() {
|
||||
let addons = await promiseAddonsByIDs(ADDON_IDS);
|
||||
await Promise.all(addons.map(addon => addon.uninstall()));
|
||||
|
||||
await promiseInstallFile(XPIS.blocklist_soft1_1);
|
||||
await promiseInstallFile(XPIS.blocklist_soft2_1);
|
||||
await promiseInstallFile(XPIS.blocklist_soft3_1);
|
||||
await promiseInstallFile(XPIS.blocklist_soft4_1);
|
||||
await promiseInstallFile(XPIS.blocklist_hard_1);
|
||||
await promiseInstallFile(XPIS.blocklist_regexp_1);
|
||||
|
||||
let [s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
await s2.enable();
|
||||
await s2.disable();
|
||||
check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
await s3.enable();
|
||||
check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
|
||||
await Pmanual_update("2");
|
||||
|
||||
[s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
// Can't manually update to a hardblocked add-on
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
|
||||
|
||||
await Pmanual_update("3");
|
||||
|
||||
[s1, s2, s3, s4, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
|
||||
|
||||
await s1.enable();
|
||||
await s2.enable();
|
||||
await s4.disable();
|
||||
});
|
||||
|
||||
// Uses the API to install blocked add-ons from the local filesystem
|
||||
add_task(async function run_local_install_test() {
|
||||
let addons = await promiseAddonsByIDs(ADDON_IDS);
|
||||
await Promise.all(addons.map(addon => addon.uninstall()));
|
||||
|
||||
await promiseInstallAllFiles([
|
||||
XPIS.blocklist_soft1_1,
|
||||
XPIS.blocklist_soft2_1,
|
||||
XPIS.blocklist_soft3_1,
|
||||
XPIS.blocklist_soft4_1,
|
||||
XPIS.blocklist_hard_1,
|
||||
XPIS.blocklist_regexp_1,
|
||||
]);
|
||||
|
||||
let installs = await AddonManager.getAllInstalls();
|
||||
// Should have finished all installs without needing to restart
|
||||
Assert.equal(installs.length, 0);
|
||||
|
||||
let [s1, s2, s3, /* s4 */, h, r] = await promiseAddonsByIDs(ADDON_IDS);
|
||||
|
||||
check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
|
||||
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
|
||||
});
|
|
@ -0,0 +1,148 @@
|
|||
/* 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 nsIBLS = Ci.nsIBlocklistService;
|
||||
|
||||
var gPluginHost = null;
|
||||
|
||||
var PLUGINS = [{
|
||||
// severity=0, vulnerabilitystatus=0 -> outdated
|
||||
name: "test_plugin_0",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// severity=0, vulnerabilitystatus=1 -> update available
|
||||
name: "test_plugin_1",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// severity=0, vulnerabilitystatus=2 -> no update
|
||||
name: "test_plugin_2",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// no severity field -> severity=3 by default -> hardblock
|
||||
name: "test_plugin_3",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// severity=1, vulnerabilitystatus=2 -> softblock
|
||||
name: "test_plugin_4",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
},
|
||||
{
|
||||
// not in the blocklist -> not blocked
|
||||
name: "test_plugin_5",
|
||||
version: "5",
|
||||
disabled: false,
|
||||
blocklisted: false,
|
||||
}];
|
||||
|
||||
async function updateBlocklist(file) {
|
||||
let blocklistUpdated = TestUtils.topicObserved("plugin-blocklist-updated");
|
||||
AddonTestUtils.loadBlocklistData(do_get_file("../data/"), file);
|
||||
return blocklistUpdated;
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
|
||||
|
||||
Services.prefs.setBoolPref("plugin.load_flash_only", false);
|
||||
gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
|
||||
await promiseStartupManager();
|
||||
});
|
||||
|
||||
add_task(async function basic() {
|
||||
await updateBlocklist("test_pluginBlocklistCtp");
|
||||
var {blocklist} = Services;
|
||||
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9"),
|
||||
nsIBLS.STATE_OUTDATED);
|
||||
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[1], "1", "1.9"),
|
||||
nsIBLS.STATE_VULNERABLE_UPDATE_AVAILABLE);
|
||||
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[2], "1", "1.9"),
|
||||
nsIBLS.STATE_VULNERABLE_NO_UPDATE);
|
||||
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[3], "1", "1.9"),
|
||||
nsIBLS.STATE_BLOCKED);
|
||||
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[4], "1", "1.9"),
|
||||
nsIBLS.STATE_SOFTBLOCKED);
|
||||
|
||||
Assert.equal(await blocklist.getPluginBlocklistState(PLUGINS[5], "1", "1.9"),
|
||||
nsIBLS.STATE_NOT_BLOCKED);
|
||||
});
|
||||
|
||||
function get_test_plugin() {
|
||||
for (var plugin of gPluginHost.getPluginTags()) {
|
||||
if (plugin.name == "Test Plug-in")
|
||||
return plugin;
|
||||
}
|
||||
Assert.ok(false, "Should have found the test plugin!");
|
||||
return null;
|
||||
}
|
||||
|
||||
// At this time, the blocklist does not have an entry for the test plugin,
|
||||
// so it shouldn't be click-to-play.
|
||||
add_task(async function test_is_not_clicktoplay() {
|
||||
var plugin = get_test_plugin();
|
||||
var blocklistState = await Blocklist.getPluginBlocklistState(plugin, "1", "1.9");
|
||||
Assert.notEqual(blocklistState, Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE);
|
||||
Assert.notEqual(blocklistState, Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
|
||||
});
|
||||
|
||||
// Here, we've updated the blocklist to have a block for the test plugin,
|
||||
// so it should be click-to-play.
|
||||
add_task(async function test_is_clicktoplay() {
|
||||
await updateBlocklist("test_pluginBlocklistCtpUndo");
|
||||
var plugin = get_test_plugin();
|
||||
var blocklistState = await Blocklist.getPluginBlocklistState(plugin, "1", "1.9");
|
||||
Assert.equal(blocklistState, Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
|
||||
});
|
||||
|
||||
// But now we've removed that entry from the blocklist (really we've gone back
|
||||
// to the old one), so the plugin shouldn't be click-to-play any more.
|
||||
add_task(async function test_is_not_clicktoplay2() {
|
||||
await updateBlocklist("test_pluginBlocklistCtp");
|
||||
var plugin = get_test_plugin();
|
||||
var blocklistState = await Blocklist.getPluginBlocklistState(plugin, "1", "1.9");
|
||||
Assert.notEqual(blocklistState, Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE);
|
||||
Assert.notEqual(blocklistState, Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
|
||||
});
|
||||
|
||||
// Test that disabling the blocklist when a plugin is ctp-blocklisted will
|
||||
// result in the plugin not being click-to-play.
|
||||
add_task(async function test_disable_blocklist() {
|
||||
await updateBlocklist("test_pluginBlocklistCtpUndo");
|
||||
var plugin = get_test_plugin();
|
||||
var blocklistState = await Blocklist.getPluginBlocklistState(plugin, "1", "1.9");
|
||||
Assert.equal(blocklistState, Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
|
||||
|
||||
Services.prefs.setBoolPref("extensions.blocklist.enabled", false);
|
||||
blocklistState = await Blocklist.getPluginBlocklistState(plugin, "1", "1.9");
|
||||
Assert.notEqual(blocklistState, Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
|
||||
Assert.notEqual(blocklistState, Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE);
|
||||
|
||||
// it should still be possible to make a plugin click-to-play via the pref
|
||||
// and setting that plugin's enabled state to click-to-play
|
||||
Services.prefs.setBoolPref("plugins.click_to_play", true);
|
||||
let previousEnabledState = plugin.enabledState;
|
||||
plugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
|
||||
Assert.equal(gPluginHost.getStateForType("application/x-test"), Ci.nsIPluginTag.STATE_CLICKTOPLAY);
|
||||
// clean up plugin state
|
||||
plugin.enabledState = previousEnabledState;
|
||||
});
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/* 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/.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MockPlugin mimics the behaviour of a plugin.
|
||||
*/
|
||||
function MockPlugin(name, version, enabledState) {
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
this.enabledState = enabledState;
|
||||
}
|
||||
|
||||
MockPlugin.prototype = {
|
||||
get disabled() {
|
||||
return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
|
||||
},
|
||||
};
|
||||
|
||||
// The mocked blocked plugin used to test the blocklist.
|
||||
const PLUGINS = [
|
||||
new MockPlugin("test_with_infoURL", "5", Ci.nsIPluginTag.STATE_ENABLED),
|
||||
new MockPlugin("test_with_altInfoURL", "5", Ci.nsIPluginTag.STATE_ENABLED),
|
||||
new MockPlugin("test_no_infoURL", "5", Ci.nsIPluginTag.STATE_ENABLED),
|
||||
new MockPlugin("test_newVersion", "1", Ci.nsIPluginTag.STATE_ENABLED),
|
||||
new MockPlugin("test_newVersion", "3", Ci.nsIPluginTag.STATE_ENABLED),
|
||||
];
|
||||
|
||||
/**
|
||||
* The entry point of the unit tests, which is also responsible of
|
||||
* copying the blocklist file to the profile folder.
|
||||
*/
|
||||
add_task(async function setup() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
|
||||
await promiseStartupManager();
|
||||
await AddonTestUtils.loadBlocklistData(do_get_file("../data"), "pluginInfoURL_block");
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that the blocklist service correctly loads and returns the infoURL for
|
||||
* a plugin that matches the first entry in the blocklist.
|
||||
*/
|
||||
add_task(async function test_infoURL() {
|
||||
// The testInfoURL must match the value within the
|
||||
// infoURL info in the pluginInfoURL_block blocklist data
|
||||
let testInfoURL = "http://test.url.com/";
|
||||
|
||||
Assert.strictEqual(await Blocklist.getPluginBlockURL(PLUGINS[0]),
|
||||
testInfoURL, "Should be the provided url when an infoURL tag is available");
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that the blocklist service correctly loads and returns the infoURL for
|
||||
* a plugin that partially matches an earlier entry in the blocklist.
|
||||
*/
|
||||
add_task(async function test_altInfoURL() {
|
||||
let altTestInfoURL = "http://alt.test.url.com/";
|
||||
|
||||
Assert.strictEqual(await Blocklist.getPluginBlockURL(PLUGINS[1]),
|
||||
altTestInfoURL, "Should be the alternative infoURL");
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that the blocklist service correctly returns the fallback value
|
||||
* if the infoURL tag is not specified in the blocklist data.
|
||||
*/
|
||||
add_task(async function test_infoURL_missing() {
|
||||
let fallback_URL = Services.prefs.getStringPref("extensions.blocklist.detailsURL")
|
||||
+ "test_plugin_noInfoURL.html";
|
||||
|
||||
Assert.strictEqual(await Blocklist.getPluginBlockURL(PLUGINS[2]), fallback_URL,
|
||||
"Should be using fallback when no infoURL tag is available.");
|
||||
});
|
||||
|
||||
add_task(async function test_intoURL_newVersion() {
|
||||
let testInfoURL = "http://test.url2.com/";
|
||||
Assert.strictEqual(await Blocklist.getPluginBlockURL(PLUGINS[3]),
|
||||
testInfoURL, "Old plugin should match");
|
||||
Assert.strictEqual(await Blocklist.getPluginBlockURL(PLUGINS[4]),
|
||||
null, "New plugin should not match");
|
||||
});
|
|
@ -0,0 +1,50 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function load_blocklist(aFile) {
|
||||
return AddonTestUtils.loadBlocklistData(do_get_file("../data"), aFile);
|
||||
}
|
||||
|
||||
// Tests that an appDisabled add-on that becomes softBlocked remains disabled
|
||||
// when becoming appEnabled
|
||||
add_task(async function test_softblock() {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
|
||||
await promiseStartupManager();
|
||||
|
||||
await promiseInstallWebExtension({
|
||||
manifest: {
|
||||
name: "Softblocked add-on",
|
||||
version: "1.0",
|
||||
applications: {
|
||||
gecko: {
|
||||
id: "softblock1@tests.mozilla.org",
|
||||
strict_min_version: "2",
|
||||
strict_max_version: "3",
|
||||
}},
|
||||
},
|
||||
});
|
||||
let s1 = await promiseAddonByID("softblock1@tests.mozilla.org");
|
||||
|
||||
// Make sure to mark it as previously enabled.
|
||||
await s1.enable();
|
||||
|
||||
Assert.ok(!s1.softDisabled);
|
||||
Assert.ok(s1.appDisabled);
|
||||
Assert.ok(!s1.isActive);
|
||||
|
||||
await load_blocklist("test_softblocked1");
|
||||
|
||||
Assert.ok(s1.softDisabled);
|
||||
Assert.ok(s1.appDisabled);
|
||||
Assert.ok(!s1.isActive);
|
||||
|
||||
AddonTestUtils.appInfo.platformVersion = "2";
|
||||
await promiseRestartManager("2");
|
||||
|
||||
s1 = await promiseAddonByID("softblock1@tests.mozilla.org");
|
||||
|
||||
Assert.ok(s1.softDisabled);
|
||||
Assert.ok(!s1.appDisabled);
|
||||
Assert.ok(!s1.isActive);
|
||||
});
|
|
@ -6,7 +6,32 @@ firefox-appdir = browser
|
|||
support-files =
|
||||
../data/**
|
||||
|
||||
[test_blocklist_appversion.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_blocklist_gfx.js]
|
||||
[test_blocklist_metadata_filters.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_blocklist_osabi.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_blocklist_plugin_flashonly.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_blocklist_plugin_outdated.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_blocklist_plugin_severities.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_blocklist_prefs.js]
|
||||
[test_blocklist_severities.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_blocklistchange.js]
|
||||
# Times out during parallel runs on desktop
|
||||
requesttimeoutfactor = 2
|
||||
[test_gfxBlacklist_Device.js]
|
||||
[test_gfxBlacklist_DriverNew.js]
|
||||
[test_gfxBlacklist_Equal_DriverNew.js]
|
||||
|
@ -25,3 +50,8 @@ support-files =
|
|||
[test_gfxBlacklist_prefs.js]
|
||||
# Bug 1248787 - consistently fails
|
||||
skip-if = true
|
||||
[test_pluginBlocklistCtp.js]
|
||||
# Bug 676992: test consistently fails on Android
|
||||
fail-if = os == "android"
|
||||
[test_pluginInfoURL.js]
|
||||
[test_softblocked.js]
|
||||
|
|
|
@ -238,7 +238,7 @@ var BlocklistPrompt = {
|
|||
|
||||
|
||||
async function loadBlocklist(file) {
|
||||
let blocklistUpdated = TestUtils.topicObserved("blocklist-updated");
|
||||
let blocklistUpdated = TestUtils.topicObserved("addon-blocklist-updated");
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url",
|
||||
"http://example.com/data/" + file);
|
||||
|
|
|
@ -41,10 +41,10 @@ MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher)
|
|||
function load_blocklist(aFile) {
|
||||
return new Promise(resolve => {
|
||||
Services.obs.addObserver(function observer() {
|
||||
Services.obs.removeObserver(observer, "blocklist-updated");
|
||||
Services.obs.removeObserver(observer, "addon-blocklist-updated");
|
||||
|
||||
resolve();
|
||||
}, "blocklist-updated");
|
||||
}, "addon-blocklist-updated");
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url",
|
||||
`http://localhost:${gPort}/data/${aFile}`);
|
||||
|
|
|
@ -138,7 +138,7 @@ const ADDONS = [
|
|||
const ADDON_IDS = ADDONS.map(a => a.id);
|
||||
|
||||
async function loadBlocklist(file) {
|
||||
let blocklistUpdated = TestUtils.topicObserved("blocklist-updated");
|
||||
let blocklistUpdated = TestUtils.topicObserved("addon-blocklist-updated");
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url",
|
||||
"http://example.com/data/" + file);
|
||||
|
|
|
@ -49,7 +49,7 @@ var BlocklistPrompt = {
|
|||
|
||||
|
||||
async function loadBlocklist(file) {
|
||||
let blocklistUpdated = TestUtils.topicObserved("blocklist-updated");
|
||||
let blocklistUpdated = TestUtils.topicObserved("plugin-blocklist-updated");
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url",
|
||||
"http://example.com/data/" + file);
|
||||
|
|
|
@ -39,9 +39,9 @@ MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher)
|
|||
function load_blocklist(aFile) {
|
||||
return new Promise(resolve => {
|
||||
Services.obs.addObserver(function observer() {
|
||||
Services.obs.removeObserver(observer, "blocklist-updated");
|
||||
Services.obs.removeObserver(observer, "addon-blocklist-updated");
|
||||
resolve();
|
||||
}, "blocklist-updated");
|
||||
}, "addon-blocklist-updated");
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url",
|
||||
`http://localhost:${gPort}/data/${aFile}`);
|
||||
|
|
|
@ -135,7 +135,7 @@ function createAddon(addon) {
|
|||
}
|
||||
|
||||
async function loadBlocklist(file, callback) {
|
||||
let blocklistUpdated = TestUtils.topicObserved("blocklist-updated");
|
||||
let blocklistUpdated = TestUtils.topicObserved("plugin-blocklist-updated");
|
||||
|
||||
gNotificationCheck = callback;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
|
|||
var testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
|
||||
|
||||
async function updateBlocklist(file) {
|
||||
let blocklistUpdated = TestUtils.topicObserved("blocklist-updated");
|
||||
let blocklistUpdated = TestUtils.topicObserved("addon-blocklist-updated");
|
||||
Blocklist.notify();
|
||||
return blocklistUpdated;
|
||||
}
|
||||
|
|
|
@ -93,13 +93,7 @@ const profileDir = gProfD.clone();
|
|||
profileDir.append("extensions");
|
||||
|
||||
function Pload_blocklist(aFile) {
|
||||
let blocklist_updated = new Promise((resolve, reject) => {
|
||||
Services.obs.addObserver(function observer() {
|
||||
Services.obs.removeObserver(observer, "blocklist-updated");
|
||||
|
||||
resolve();
|
||||
}, "blocklist-updated");
|
||||
});
|
||||
let blocklist_updated = TestUtils.topicObserved("addon-blocklist-updated");
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", "http://example.com/data/blocklistchange/" + aFile);
|
||||
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
|
||||
|
|
|
@ -57,7 +57,7 @@ async function updateBlocklist(blocklistURL) {
|
|||
if (blocklistURL) {
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", blocklistURL);
|
||||
}
|
||||
let blocklistUpdated = TestUtils.topicObserved("blocklist-updated");
|
||||
let blocklistUpdated = TestUtils.topicObserved("plugin-blocklist-updated");
|
||||
gNotifier.notify(null);
|
||||
return blocklistUpdated;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ testserver.registerDirectory("/data/", do_get_file("../data"));
|
|||
function load_blocklist(aFile) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Services.obs.addObserver(function observer() {
|
||||
Services.obs.removeObserver(observer, "blocklist-updated");
|
||||
Services.obs.removeObserver(observer, "addon-blocklist-updated");
|
||||
|
||||
resolve();
|
||||
}, "blocklist-updated");
|
||||
}, "addon-blocklist-updated");
|
||||
|
||||
Services.prefs.setCharPref("extensions.blocklist.url", `http://localhost:${gPort}/data/${aFile}`);
|
||||
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
|
||||
|
|
Загрузка…
Ссылка в новой задаче