mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 611076: Cancelling an AddonInstall that has been redirected to a new URL isn't possible. r=robstrong, a=blocks-betaN
This commit is contained in:
parent
50d16e80b9
commit
931cfb3025
@ -4927,14 +4927,7 @@ AddonInstall.prototype = {
|
||||
XPIProvider.removeActiveInstall(this);
|
||||
AddonManagerPrivate.callInstallListeners("onDownloadCancelled",
|
||||
this.listeners, this.wrapper);
|
||||
if (this.file && !(this.sourceURI instanceof Ci.nsIFileURL)) {
|
||||
try {
|
||||
this.file.remove(true);
|
||||
}
|
||||
catch (e) {
|
||||
WARN("Failed to remove temporary file " + this.file.path, e);
|
||||
}
|
||||
}
|
||||
this.removeTemporaryFile();
|
||||
break;
|
||||
case AddonManager.STATE_INSTALLED:
|
||||
LOG("Cancelling install of " + this.addon.id);
|
||||
@ -5322,6 +5315,8 @@ AddonInstall.prototype = {
|
||||
this.badCertHandler.asyncOnChannelRedirect(aOldChannel, aNewChannel, aFlags, aCallback);
|
||||
else
|
||||
aCallback.onRedirectVerifyCallback(Cr.NS_OK);
|
||||
|
||||
this.channel = aNewChannel;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -5377,8 +5372,10 @@ AddonInstall.prototype = {
|
||||
Services.obs.removeObserver(this, "network:offline-about-to-go-offline");
|
||||
|
||||
// If the download was cancelled then all events will have already been sent
|
||||
if (aStatus == Cr.NS_BINDING_ABORTED)
|
||||
if (aStatus == Cr.NS_BINDING_ABORTED) {
|
||||
this.removeTemporaryFile();
|
||||
return;
|
||||
}
|
||||
|
||||
LOG("Download of " + this.sourceURI.spec + " completed.");
|
||||
|
||||
|
@ -157,8 +157,11 @@ Installer.prototype = {
|
||||
}, this);
|
||||
}
|
||||
break;
|
||||
case AddonManager.STATE_CANCELLED:
|
||||
// Just ignore cancelled downloads
|
||||
break;
|
||||
default:
|
||||
WARN("Download of " + install.sourceURI + " in unexpected state " +
|
||||
WARN("Download of " + install.sourceURI.spec + " in unexpected state " +
|
||||
install.state);
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,11 @@ function run_test() {
|
||||
testserver = new nsHttpServer();
|
||||
testserver.registerDirectory("/addons/", do_get_file("addons"));
|
||||
testserver.registerDirectory("/data/", do_get_file("data"));
|
||||
testserver.registerPathHandler("/redirect", function(aRequest, aResponse) {
|
||||
aResponse.setStatusLine(null, 301, "Moved Permanently");
|
||||
let url = aRequest.host + ":" + aRequest.port + aRequest.queryString;
|
||||
aResponse.setHeader("Location", "http://" + url);
|
||||
});
|
||||
testserver.start(4444);
|
||||
|
||||
do_test_pending();
|
||||
@ -1466,6 +1471,46 @@ function run_test_25() {
|
||||
|
||||
ensure_test_completed();
|
||||
|
||||
end_test();
|
||||
run_test_26();
|
||||
}, "application/x-xpinstall", do_get_addon_hash("test_install3"));
|
||||
}
|
||||
|
||||
function run_test_26() {
|
||||
prepare_test({ }, [
|
||||
"onNewInstall",
|
||||
"onDownloadStarted",
|
||||
"onDownloadCancelled"
|
||||
]);
|
||||
|
||||
let observerService = AM_Cc["@mozilla.org/network/http-activity-distributor;1"].
|
||||
getService(AM_Ci.nsIHttpActivityDistributor);
|
||||
observerService.addObserver({
|
||||
observeActivity: function(aChannel, aType, aSubtype, aTimestamp, aSizeData,
|
||||
aStringData) {
|
||||
aChannel.QueryInterface(AM_Ci.nsIChannel);
|
||||
// Wait for the final event for the redirected URL
|
||||
if (aChannel.URI.spec != "http://localhost:4444/addons/test_install1.xpi" ||
|
||||
aType != AM_Ci.nsIHttpActivityObserver.ACTIVITY_TYPE_HTTP_TRANSACTION ||
|
||||
aSubtype != AM_Ci.nsIHttpActivityObserver.ACTIVITY_SUBTYPE_TRANSACTION_CLOSE)
|
||||
return;
|
||||
|
||||
// Request should have been cancelled
|
||||
do_check_eq(aChannel.status, Components.results.NS_BINDING_ABORTED);
|
||||
|
||||
observerService.removeObserver(this);
|
||||
|
||||
do_test_finished();
|
||||
}
|
||||
});
|
||||
|
||||
let url = "http://localhost:4444/redirect?/addons/test_install1.xpi";
|
||||
AddonManager.getInstallForURL(url, function(aInstall) {
|
||||
aInstall.addListener({
|
||||
onDownloadProgress: function(aInstall) {
|
||||
aInstall.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
aInstall.install();
|
||||
}, "application/x-xpinstall");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user