Bug 1304379: Don't create an extra browser if panel.show is called multiple times. r?krizsa
MozReview-Commit-ID: 1rvHg6x976z
--- 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);
}