From 8a349801dcc2f69d1a16499070f10802e046c06e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 10 May 2022 14:15:57 +0200 Subject: [PATCH] [Firefox viewer] Stop using `FirefoxCom.requestAsync` in the `DownloadManager` After the changes in https://bugzilla.mozilla.org/show_bug.cgi?id=1757771, that simplified the MOZCENTRAL downloading code, the `ChromeActions.download`-method will no longer invoke the `sendResponse`-callback. Hence it should no longer be necessary for the `DownloadManager`, in the MOZCENTRAL viewer, to use `FirefoxCom.requestAsync` since no response is ever provided.[1] For the allocated BlobURLs, they should (hopefully) be released when navigating away from the viewer. --- [1] Note that that was *already* the case, for one of the previous code-paths in the `ChromeActions.download`-method. --- web/firefoxcom.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/web/firefoxcom.js b/web/firefoxcom.js index 040819e60..ecbb10eeb 100644 --- a/web/firefoxcom.js +++ b/web/firefoxcom.js @@ -116,13 +116,11 @@ class DownloadManager { new Blob([data], { type: contentType }) ); - FirefoxCom.requestAsync("download", { + FirefoxCom.request("download", { blobUrl, originalUrl: blobUrl, filename, isAttachment: true, - }).then(error => { - URL.revokeObjectURL(blobUrl); }); } @@ -161,17 +159,10 @@ class DownloadManager { download(blob, url, filename) { const blobUrl = URL.createObjectURL(blob); - FirefoxCom.requestAsync("download", { + FirefoxCom.request("download", { blobUrl, originalUrl: url, filename, - }).then(error => { - if (error) { - // If downloading failed in `PdfStreamConverter.jsm` it's very unlikely - // that attempting to fallback and re-download would be helpful here. - console.error("`ChromeActions.download` failed."); - } - URL.revokeObjectURL(blobUrl); }); } }