Bug 1305148: Ignore panel.resize when the panel isn't visible. r?krizsa draft
authorKris Maglione <maglione.k@gmail.com>
Wed, 28 Sep 2016 22:18:09 +0100
changeset 418634 c25c3808c0dc8ae7c3eebfba85713c1cbad75784
parent 418633 a63181938c7a4b1dab7dd804e612c63153fe220a
child 532399 291e6f14998c897014351fce66c7f211bcf35d89
push id30737
push usermaglione.k@gmail.com
push dateWed, 28 Sep 2016 21:21:25 +0000
reviewerskrizsa
bugs1305148
milestone52.0a1
Bug 1305148: Ignore panel.resize when the panel isn't visible. r?krizsa MozReview-Commit-ID: BFPZm3wUKf2
addon-sdk/source/lib/sdk/panel/utils.js
addon-sdk/source/test/test-panel.js
--- 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>';