зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1518663 - If policy extension download fails, try again. r=Felipe
Differential Revision: https://phabricator.services.mozilla.com/D25830 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
13610b62ba
Коммит
86ddad7766
|
@ -552,6 +552,7 @@ var Policies = {
|
|||
onDownloadFailed: () => {
|
||||
install.removeListener(listener);
|
||||
log.error(`Download failed - ${location}`);
|
||||
clearRunOnceModification("extensionsInstall");
|
||||
},
|
||||
onInstallFailed: () => {
|
||||
install.removeListener(listener);
|
||||
|
@ -1143,6 +1144,16 @@ async function runOncePerModification(actionName, policyValue, callback) {
|
|||
return callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* clearRunOnceModification
|
||||
*
|
||||
* Helper function that clears a runOnce policy.
|
||||
*/
|
||||
function clearRunOnceModification(actionName) {
|
||||
let prefName = `browser.policies.runOncePerModification.${actionName}`;
|
||||
Services.prefs.clearUserPref(prefName);
|
||||
}
|
||||
|
||||
let gChromeURLSBlocked = false;
|
||||
|
||||
// If any about page is blocked, we block the loading of all
|
||||
|
|
|
@ -92,21 +92,43 @@ add_task(async function test_addon_uninstall() {
|
|||
is(addon, null, "Addon should be uninstalled.");
|
||||
});
|
||||
|
||||
add_task(async function test_addon_download_failure() {
|
||||
// Test that if the download fails, the runOnce pref
|
||||
// is cleared so that the dowbnload will happen again
|
||||
|
||||
let installPromise = wait_for_addon_install();
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": {
|
||||
"Extensions": {
|
||||
"Install": [
|
||||
`${BASE_URL}/policytest_invalid.xpi`,
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
await installPromise;
|
||||
} catch (e) {}
|
||||
is(Services.prefs.prefHasUserValue("browser.policies.runOncePerModification.extensionsInstall"), false, "runOnce pref should be unset");
|
||||
});
|
||||
|
||||
function wait_for_addon_install() {
|
||||
return new Promise((resolve, reject) => {
|
||||
AddonManager.addInstallListener({
|
||||
onInstallEnded(install, addon) {
|
||||
if (addon.id == addonID) {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
onDownloadFailed: (install) => {
|
||||
reject();
|
||||
},
|
||||
onInstallFailed: (install) => {
|
||||
reject();
|
||||
},
|
||||
});
|
||||
let listener = {};
|
||||
listener.onInstallEnded = (install, addon) => {
|
||||
AddonManager.removeInstallListener(listener);
|
||||
resolve();
|
||||
};
|
||||
listener.onDownloadFailed = install => {
|
||||
AddonManager.removeInstallListener(listener);
|
||||
reject();
|
||||
};
|
||||
listener.onInstallFailed = install => {
|
||||
AddonManager.removeInstallListener(listener);
|
||||
reject();
|
||||
};
|
||||
AddonManager.addInstallListener(listener);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче