diff --git a/mail/app/profile/all-thunderbird.js b/mail/app/profile/all-thunderbird.js index 169a7bb20e..9d7dc58abd 100644 --- a/mail/app/profile/all-thunderbird.js +++ b/mail/app/profile/all-thunderbird.js @@ -173,6 +173,11 @@ pref("extensions.overlayloader.loglevel", "warn"); pref("extensions.abuseReport.enabled", false); +// Delay opening of action popups until the browser is fully loaded. +// This is needed on Wayland systems, but can be enabled for other +// systems for debug purposes as well. See Bug 1905622. +pref("extensions.openPopupDelayedFullyLoaded.enabled", false); + // Strict compatibility makes add-ons incompatible by default. #ifndef RELEASE_OR_BETA pref("extensions.strictCompatibility", false); diff --git a/mail/components/extensions/ExtensionPopups.sys.mjs b/mail/components/extensions/ExtensionPopups.sys.mjs index 801d1afea1..8052807380 100644 --- a/mail/components/extensions/ExtensionPopups.sys.mjs +++ b/mail/components/extensions/ExtensionPopups.sys.mjs @@ -44,6 +44,7 @@ export class BasePopup { this.contentReady = new Promise(resolve => { this._resolveContentReady = resolve; }); + this.contentReadyAndResized = Promise.withResolvers(); this.window.addEventListener("unload", this); this.viewNode.addEventListener("popuphiding", this); @@ -160,6 +161,10 @@ export class BasePopup { case "Extension:BrowserResized": this._resolveContentReady(); + // The final resize is marked as delayed, which is the one we have to wait for. + if (data.detail == "delayed") { + this.contentReadyAndResized.resolve(); + } if (this.ignoreResizes) { this.dimensions = data; } else { diff --git a/mail/components/extensions/ExtensionToolbarButtons.sys.mjs b/mail/components/extensions/ExtensionToolbarButtons.sys.mjs index e2131dcdf4..86396604da 100644 --- a/mail/components/extensions/ExtensionToolbarButtons.sys.mjs +++ b/mail/components/extensions/ExtensionToolbarButtons.sys.mjs @@ -493,6 +493,19 @@ export class ToolbarButtonAPI extends ExtensionAPIPersistent { const popup = lazy.ViewPopup.for(this.extension, window.top) || this.getPopup(window.top, popupURL); + + // Bug 1905622: We have to delay opening the panel, until after its browser + // has been loaded, otherwise the content will be blank. + if ( + popup.viewNode.isWaylandPopup || + Services.prefs.getBoolPref( + "extensions.openPopupDelayedFullyLoaded.enabled" + ) + ) { + await popup.browserLoaded; + await popup.contentReadyAndResized.promise; + } + popup.viewNode.openPopup(button, "bottomleft topleft", 0, 0); } else if (!options.requirePopupUrl) { if (!this.lastClickInfo) {