Bug 1442187: Wait until next tick after popupshown before resolving show(). r?Gijs
With the migration of Promise microtasks to the main microtask queue, promise
resolution handlers are now called immediately after any JS event listener
returns. The result of this is that in the case of the show() method, the
resolution handlers now run before the view's own popupshown handlers run and
the view is set active, which breaks handlers which expect it to act more
sensibly.
By deferring the resolution until the next tick, the resolution handlers are
called when the view is visible and in a consistent state.
MozReview-Commit-ID: C7697CBoHFt
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -4288,17 +4288,20 @@ OverflowableToolbar.prototype = {
PanelMultiView.openPopup(this._panel, anchor || this._chevron, {
triggerEvent: aEvent,
}).catch(Cu.reportError);
this._chevron.open = true;
this._panel.addEventListener("popupshown", () => {
this._panel.addEventListener("dragover", this);
this._panel.addEventListener("dragend", this);
- resolve();
+ // Wait until the next tick to resolve so all popupshown
+ // handlers have a chance to run before our promise resolution
+ // handlers do.
+ Services.tm.dispatchToMainThread(resolve);
}, {once: true});
});
},
_onClickChevron(aEvent) {
if (this._chevron.open) {
this._chevron.open = false;
PanelMultiView.hidePopup(this._panel);