diff --git a/mail/components/preferences/subdialogs.js b/mail/components/preferences/subdialogs.js index 12be9c1429..15fd4529e3 100644 --- a/mail/components/preferences/subdialogs.js +++ b/mail/components/preferences/subdialogs.js @@ -71,6 +71,16 @@ SubDialog.prototype = { async open(aURL, aFeatures = null, aParams = null, aClosingCallback = null) { // Wait until frame is ready to prevent browser crash in tests await this._frameCreated; + + if (!this._frame.contentWindow) { + // Given the binding constructor execution is asynchronous, and "load" + // event can be dispatched before the browser element is shown, the + // browser binding might not be constructed at this point. Forcibly + // construct the frame and construct the binding. + // FIXME: Remove this (bug 1437247) + this._frame.getBoundingClientRect(); + } + // If we're open on some (other) URL or we're closing, open when closing has finished. if (this._openedURL || this._isClosing) { if (!this._isClosing) { @@ -511,6 +521,12 @@ var gSubDialog = { return; } + if (this._dialogs.length == 0) { + // When opening the first dialog, show the dialog stack to make sure + // the browser binding can be constructed. + this._dialogStack.hidden = false; + } + this._preloadDialog.open(aURL, aFeatures, aParams, aClosingCallback); this._dialogs.push(this._preloadDialog); this._preloadDialog = new SubDialog({template: this._dialogTemplate, @@ -518,7 +534,6 @@ var gSubDialog = { id: this._nextDialogID++}); if (this._dialogs.length == 1) { - this._dialogStack.hidden = false; this._ensureStackEventListeners(); } },