Bug 1491601 - Synchronize subdialog.js with M-C to fix JS TypeError. r=jorgk

This commit is contained in:
Richard Marti 2018-10-07 10:06:02 +02:00
Родитель bbf668b567
Коммит c833ec3b6d
1 изменённых файлов: 19 добавлений и 6 удалений

Просмотреть файл

@ -43,7 +43,8 @@ SubDialog.prototype = {
"chrome://messenger/skin/preferences/preferences.css",
"chrome://global/skin/in-content/common.css",
"chrome://messenger/skin/preferences/aboutPreferences.css",
"chrome://messenger/skin/preferences/dialog.css"],
"chrome://messenger/skin/preferences/dialog.css",
],
// Store the original instantApply pref for restoring after closing the dialog
_instantApplyOrig: Services.prefs.getBoolPref("browser.preferences.instantApply"),
@ -86,8 +87,9 @@ SubDialog.prototype = {
if (!this._isClosing) {
this.close();
}
let args = Array.from(arguments);
this._closingPromise.then(() => {
this.open(aURL, aFeatures, aParams, aClosingCallback);
this.open.apply(this, args);
});
return;
}
@ -159,7 +161,9 @@ SubDialog.prototype = {
}
};
this._frame.addEventListener("load", onBlankLoad);
this._frame.loadURI("about:blank");
this._frame.loadURI("about:blank", {
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
});
}, 0);
},
@ -288,7 +292,16 @@ SubDialog.prototype = {
let frameSizeDifference = (frameRect.top - boxRect.top) + (boxRect.bottom - frameRect.bottom);
// Then determine and set a bunch of width stuff:
let frameMinWidth = docEl.style.width || docEl.scrollWidth + "px";
let frameMinWidth = docEl.style.width;
if (!frameMinWidth) {
if (docEl.ownerDocument.body) {
// HTML documents have a body but XUL documents don't
frameMinWidth = docEl.ownerDocument.body.scrollWidth;
} else {
frameMinWidth = docEl.scrollWidth;
}
frameMinWidth += "px";
}
let frameWidth = docEl.getAttribute("width") ? docEl.getAttribute("width") + "px" :
frameMinWidth;
this._frame.style.width = frameWidth;
@ -314,8 +327,7 @@ SubDialog.prototype = {
} else if (frameHeight.endsWith("px")) {
comparisonFrameHeight = parseFloat(frameHeight, 10);
} else {
Cu.reportError(
"This dialog (" + this._frame.contentWindow.location.href + ") " +
Cu.reportError("This dialog (" + this._frame.contentWindow.location.href + ") " +
"set a height in non-px-non-em units ('" + frameHeight + "'), " +
"which is likely to lead to bad sizing in in-content preferences. " +
"Please consider changing this.");
@ -345,6 +357,7 @@ SubDialog.prototype = {
this._overlay.style.opacity = ""; // XXX: focus hack continued from _onContentLoaded
if (this._box.getAttribute("resizable") == "true") {
this._onResize = this._onResize.bind(this);
this._resizeObserver = new MutationObserver(this._onResize);
this._resizeObserver.observe(this._box, {attributes: true});
}