Bug 1305148: Ignore panel.resize when the panel isn't visible. r?krizsa
MozReview-Commit-ID: BFPZm3wUKf2
--- a/addon-sdk/source/lib/sdk/panel/utils.js
+++ b/addon-sdk/source/lib/sdk/panel/utils.js
@@ -101,18 +101,20 @@ function close(panel) {
return panel.hidePopup && panel.hidePopup();
}
exports.close = close
function resize(panel, width, height) {
// Resize the iframe instead of using panel.sizeTo
// because sizeTo doesn't work with arrow panels
- panel.firstChild.style.width = width + "px";
- panel.firstChild.style.height = height + "px";
+ if (panel.firstChild) {
+ panel.firstChild.style.width = width + "px";
+ panel.firstChild.style.height = height + "px";
+ }
}
exports.resize = resize
function display(panel, options, anchor) {
let document = panel.ownerDocument;
let x, y;
let { width, height, defaultWidth, defaultHeight } = options;
--- a/addon-sdk/source/test/test-panel.js
+++ b/addon-sdk/source/test/test-panel.js
@@ -249,16 +249,20 @@ exports["test Resize Panel"] = function(
let panel = Panel({
contentScript: "self.postMessage('')",
contentScriptWhen: "end",
contentURL: "data:text/html;charset=utf-8,",
height: 10,
width: 10,
onMessage: function (message) {
+ // Make sure that attempting to resize a panel while it isn't
+ // visible doesn't cause an error.
+ panel.resize(1, 1);
+
panel.show();
},
onShow: function () {
panel.resize(100,100);
panel.hide();
},
onHide: function () {
assert.ok((panel.width == 100) && (panel.height == 100),
@@ -327,17 +331,17 @@ exports["test Several Show Hides"] = fun
}
});
panel.on('error', function(e) {
assert.fail('error was emitted:' + e.message + '\n' + e.stack);
});
panel.show();
};
-exports["test Anchor And Arrow"] = function(assert, done) {
+exports["test Anchor And Arrow"] = function*(assert, done) {
let { loader } = LoaderWithHookedConsole(module, ignorePassingDOMNodeWarning);
let { Panel } = loader.require('sdk/panel');
let count = 0;
let url = 'data:text/html;charset=utf-8,' +
'<html><head><title>foo</title></head><body>' +
'</body></html>';