Use global counter for hidden browsers

This commit is contained in:
Simon Kornblith 2012-11-07 17:17:16 -05:00
parent 3c52b422fa
commit 7754d530da

View file

@ -2396,6 +2396,8 @@ Zotero.DragDrop = {
* Functions for creating and destroying hidden browser objects * Functions for creating and destroying hidden browser objects
**/ **/
Zotero.Browser = new function() { Zotero.Browser = new function() {
var nBrowsers = 0;
this.createHiddenBrowser = createHiddenBrowser; this.createHiddenBrowser = createHiddenBrowser;
this.deleteHiddenBrowser = deleteHiddenBrowser; this.deleteHiddenBrowser = deleteHiddenBrowser;
@ -2423,8 +2425,7 @@ Zotero.Browser = new function() {
hiddenBrowser.docShell.allowJavascript = true; hiddenBrowser.docShell.allowJavascript = true;
hiddenBrowser.docShell.allowMetaRedirects = false; hiddenBrowser.docShell.allowMetaRedirects = false;
hiddenBrowser.docShell.allowPlugins = false; hiddenBrowser.docShell.allowPlugins = false;
Zotero.debug("Created hidden browser (" Zotero.debug("Created hidden browser (" + (nBrowsers++) + ")");
+ (win.document.getElementsByTagName('browser').length - 1) + ")");
return hiddenBrowser; return hiddenBrowser;
} }
@ -2436,8 +2437,7 @@ Zotero.Browser = new function() {
myBrowser.destroy(); myBrowser.destroy();
myBrowser.parentNode.removeChild(myBrowser); myBrowser.parentNode.removeChild(myBrowser);
myBrowser = null; myBrowser = null;
Zotero.debug("Deleted hidden browser (" Zotero.debug("Deleted hidden browser (" + (--nBrowsers) + ")");
+ (win.document.getElementsByTagName('browser').length - 1) + ")");
} }
} }
} }