Bug 1305148: Ignore panel.resize when the panel isn't visible. r=gabor
authorKris Maglione <maglione.k@gmail.com>
Wed, 28 Sep 2016 22:18:09 +0100
changeset 316081 e517fba7718a4ffd0c7dbfc1d133da7dc39e71f3
parent 316080 d89bdc2d9f01f68fa74781e57ab582b15c2738a7
child 316082 56f95c86c04c893ecf87a0dad7b2d1ff91b5b1c7
push id30759
push userphilringnalda@gmail.com
push dateSat, 01 Oct 2016 06:25:09 +0000
treeherdermozilla-central@fcc62bbf09ee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1305148
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1305148: Ignore panel.resize when the panel isn't visible. r=gabor 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),
@@ -330,17 +334,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>';