Bug 1305148: Ignore panel.resize when the panel isn't visible. r=gabor a=ritu
authorKris Maglione <maglione.k@gmail.com>
Wed, 28 Sep 2016 22:18:09 +0100
changeset 348431 9d64a6fe3f456e42680b90ba4cd6afb22e9aca79
parent 348430 437d50a541e27bcc1b4a2f209e7cbfbeb91a5995
child 348432 f8030737176ad4dae8a678650be7b05635142e7a
push id6442
push userkwierso@gmail.com
push dateMon, 03 Oct 2016 20:03:56 +0000
treeherdermozilla-beta@2c7126354104 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor, ritu
bugs1305148
milestone50.0
Bug 1305148: Ignore panel.resize when the panel isn't visible. r=gabor a=ritu 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>';