Bug 1304379: Don't create an extra browser if panel.show is called multiple times. r?krizsa draft
authorKris Maglione <maglione.k@gmail.com>
Wed, 28 Sep 2016 22:07:02 +0100
changeset 418633 a63181938c7a4b1dab7dd804e612c63153fe220a
parent 418632 d3d45f7fa087c2c15742bd572ec45e01d1151911
child 418634 c25c3808c0dc8ae7c3eebfba85713c1cbad75784
push id30737
push usermaglione.k@gmail.com
push dateWed, 28 Sep 2016 21:21:25 +0000
reviewerskrizsa
bugs1304379
milestone52.0a1
Bug 1304379: Don't create an extra browser if panel.show is called multiple times. r?krizsa MozReview-Commit-ID: 1rvHg6x976z
addon-sdk/source/lib/sdk/panel/utils.js
--- a/addon-sdk/source/lib/sdk/panel/utils.js
+++ b/addon-sdk/source/lib/sdk/panel/utils.js
@@ -182,22 +182,24 @@ function display(panel, options, anchor)
     popupPosition = vertical + "center " + verticalInverse + horizontal;
 
     // Allow panel to flip itself if the panel can't be displayed at the
     // specified position (useful if we compute a bad position or if the
     // user moves the window and panel remains visible)
     panel.setAttribute("flip", "both");
   }
 
-  panel.viewFrame = document.importNode(panel.backgroundFrame, false);
-  panel.appendChild(panel.viewFrame);
+  if (!panel.viewFrame) {
+    panel.viewFrame = document.importNode(panel.backgroundFrame, false);
+    panel.appendChild(panel.viewFrame);
 
-  let {privateBrowsingId} = getDocShell(panel.viewFrame).getOriginAttributes();
-  let principal = Services.scriptSecurityManager.createNullPrincipal({privateBrowsingId});
-  getDocShell(panel.viewFrame).createAboutBlankContentViewer(principal);
+    let {privateBrowsingId} = getDocShell(panel.viewFrame).getOriginAttributes();
+    let principal = Services.scriptSecurityManager.createNullPrincipal({privateBrowsingId});
+    getDocShell(panel.viewFrame).createAboutBlankContentViewer(principal);
+  }
 
   // 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";
 
   panel.openPopup(anchor, popupPosition, x, y);
 }