diff --git a/addon-sdk/source/lib/sdk/panel/utils.js b/addon-sdk/source/lib/sdk/panel/utils.js index e0903f1970ba..56e8bd78dcf5 100644 --- a/addon-sdk/source/lib/sdk/panel/utils.js +++ b/addon-sdk/source/lib/sdk/panel/utils.js @@ -106,8 +106,10 @@ 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 diff --git a/addon-sdk/source/test/test-panel.js b/addon-sdk/source/test/test-panel.js index 34dd201097aa..13776e9dbc3e 100644 --- a/addon-sdk/source/test/test-panel.js +++ b/addon-sdk/source/test/test-panel.js @@ -254,6 +254,10 @@ exports["test Resize Panel"] = function(assert, done) { 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 () { @@ -335,7 +339,7 @@ exports["test Several Show Hides"] = function(assert, done) { 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');