Bug 1096971 - Don't propagate an error when the package downloaded was the same we had. r=fabrice

This commit is contained in:
Antonio M. Amaya 2014-11-17 02:01:00 +01:00
parent 123849abdb
commit f748c30af9
2 changed files with 20 additions and 5 deletions

View File

@ -3263,7 +3263,7 @@ this.DOMApplicationRegistry = {
// can proceed to access the app. We also throw an error to alert
// the caller that the package wasn't downloaded.
this._sendAppliedEvent(aOldApp);
throw new Error("PACKAGE_UNCHANGED");
throw "PACKAGE_UNCHANGED";
}
let newManifest = yield this._openAndReadPackage(zipFile, aOldApp, aNewApp,
@ -3922,6 +3922,13 @@ this.DOMApplicationRegistry = {
return;
}
// If the error that got us here was that the package hasn't changed,
// since we already sent a success and an applied, let's not confuse
// the clients...
if (aError == "PACKAGE_UNCHANGED") {
return;
}
let download = AppDownloadManager.get(aNewApp.manifestURL);
aOldApp.downloading = false;

View File

@ -72,12 +72,13 @@ function checkLastAppState(aMiniManifestURL, aExpectedReady, aExpectedDownload,
expected, true, false, aCb);
}
function updateApp(aExpectedReady, aPreviousVersion, aNextVersion) {
function updateApp(aExpectedReady, aPreviousVersion, aNextVersion, aFailOnError) {
var lApp = PackagedTestHelper.gApp;
var ondownloadappliedhandler =
checkLastAppState.bind(PackagedTestHelper, miniManifestURL, false, false,
aNextVersion, PackagedTestHelper.next);
aNextVersion,
setTimeout.bind(undefined, PackagedTestHelper.next, 500));
var ondownloadsuccesshandler =
checkLastAppState.bind(undefined, miniManifestURL,
@ -86,8 +87,15 @@ function updateApp(aExpectedReady, aPreviousVersion, aNextVersion) {
navigator.mozApps.mgmt.applyDownload(lApp);
});
var ondownloaderrorhandler = aFailOnError ?
function() {
ok(false, "We should not get an error but got " +
lApp.downloadError.name);
PackagedTestHelper.finish();
} : null;
checkForUpdate(true, ondownloadsuccesshandler, ondownloadappliedhandler,
null, true);
ondownloaderrorhandler, true);
}
@ -238,7 +246,7 @@ var steps = [
},
function() {
info("== TEST == Update packaged app - same package");
updateApp(false, 3, 3);
updateApp(false, 3, 3, true);
},
function() {
info("== TEST == Check for Update after getting the same package");