From 26dd94a024f21971e539a8650c2f177323c98fe2 Mon Sep 17 00:00:00 2001 From: Arturo Mejia Date: Sun, 4 Feb 2024 18:23:43 +0000 Subject: [PATCH] Bug 1868249 - Allow pending gecko results to be resolves when canceling an add-on installation. r=willdurand Differential Revision: https://phabricator.services.mozilla.com/D196353 --- .../modules/geckoview/GeckoViewWebExtension.sys.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mobile/android/modules/geckoview/GeckoViewWebExtension.sys.mjs b/mobile/android/modules/geckoview/GeckoViewWebExtension.sys.mjs index 49a022b30ce0..7da03844b0db 100644 --- a/mobile/android/modules/geckoview/GeckoViewWebExtension.sys.mjs +++ b/mobile/android/modules/geckoview/GeckoViewWebExtension.sys.mjs @@ -424,8 +424,15 @@ class ExtensionInstallListener { try { this.install.cancel(); cancelled = true; - } catch (_) { + } catch (ex) { // install may have already failed or been cancelled + debug`Unable to cancel the install installId ${installId}, Error: ${ex}`; + // When we attempt to cancel an install but the cancellation fails for + // some reasons (e.g., because it is too late), we need to revert this + // boolean property to allow another cancellation to be possible. + // Otherwise, events like `onDownloadCancelled` won't resolve and that + // will cause problems in the embedder. + this.cancelling = false; } aCallback.onSuccess({ cancelled }); break;