Bug 1304379 - Don't create an extra browser if panel.show is called multiple times. r=gabor, a=ritu
authorKris Maglione <maglione.k@gmail.com>
Wed, 28 Sep 2016 22:07:02 +0100
changeset 350488 e8610794c3977cb0acb4ccf141e945b0ca1409df
parent 350487 3e6aaad787686b864562990d1a374c9085aa8703
child 350489 47dff98b4b466b0b373ff04a2bb95542260be0c3
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor, ritu
bugs1304379
milestone50.0
Bug 1304379 - Don't create an extra browser if panel.show is called multiple times. r=gabor, a=ritu 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);
 }