mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 989137 - Part 13: Ability to ignore hashes of downloaded experiments. r=gfritzsche
This commit is contained in:
parent
6f0f2c7b08
commit
66edbad45a
@ -263,6 +263,10 @@ Experiments.Policy = function () {
|
||||
this._log = Log.repository.getLoggerWithMessagePrefix(
|
||||
"Browser.Experiments.Policy",
|
||||
"Policy #" + gPolicyCounter++ + "::");
|
||||
|
||||
// Set to true to ignore hash verification on downloaded XPIs. This should
|
||||
// not be used outside of testing.
|
||||
this.ignoreHashes = false;
|
||||
};
|
||||
|
||||
Experiments.Policy.prototype = {
|
||||
@ -1498,8 +1502,9 @@ Experiments.ExperimentEntry.prototype = {
|
||||
_installAddon: Task.async(function* () {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let install = yield addonInstallForURL(this._manifestData.xpiURL,
|
||||
this._manifestData.xpiHash);
|
||||
let hash = this._policy.ignoreHashes ? null : this._manifestData.xpiHash;
|
||||
|
||||
let install = yield addonInstallForURL(this._manifestData.xpiURL, hash);
|
||||
gActiveInstallURLs.add(install.sourceURI.spec);
|
||||
|
||||
let failureHandler = (install, handler) => {
|
||||
|
@ -141,4 +141,23 @@ add_task(function* test_startStop() {
|
||||
Assert.equal(experiment.enabled, false, "Experiment should be disabled.");
|
||||
addons = yield getExperimentAddons();
|
||||
Assert.equal(addons.length, 0, "Experiment add-on is uninstalled.");
|
||||
|
||||
// Ensure hash validation works.
|
||||
// We set an incorrect hash and expect the install to fail.
|
||||
experiment._manifestData.xpiHash = "sha1:41014dcc66b4dcedcd973491a1530a32f0517d8a";
|
||||
let errored = false;
|
||||
try {
|
||||
yield experiment.start();
|
||||
} catch (ex) {
|
||||
errored = true;
|
||||
}
|
||||
Assert.ok(experiment._failedStart, "Experiment failed to start.");
|
||||
Assert.ok(errored, "start() threw an exception.");
|
||||
|
||||
// Make sure "ignore hashes" mode works.
|
||||
gPolicy.ignoreHashes = true;
|
||||
let changes = yield experiment.start();
|
||||
Assert.equal(changes, experiment.ADDON_CHANGE_INSTALL);
|
||||
yield experiment.stop();
|
||||
gPolicy.ignoreHashes = false;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user