From 8deb7043fcc4c1a9cc2a86bd18ed1369bb8747a3 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 6 Feb 2011 07:16:10 +0000 Subject: [PATCH] use getXULWindowEnumerator to work around a bug I encountered on Linux (even though this code was based on an example on MDC, apparently it doesn't work quite right) --- chrome/content/zotero/tab.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/tab.js b/chrome/content/zotero/tab.js index be8b493b7..eeffc84af 100644 --- a/chrome/content/zotero/tab.js +++ b/chrome/content/zotero/tab.js @@ -32,12 +32,15 @@ var ZoteroTab = new function() // find window this tab is loaded in var windowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); - var enumerator = windowMediator.getZOrderDOMWindowEnumerator("navigator:browser", true); + var enumerator = windowMediator.getXULWindowEnumerator("navigator:browser"); while(enumerator.hasMoreElements()) { - var window = enumerator.getNext(); + var xulwin = enumerator.getNext().QueryInterface(Components.interfaces.nsIXULWindow); + var window = xulwin.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsIDOMWindow); var browserIndex = window.gBrowser.getBrowserIndexForDocument(document); if(browserIndex !== -1) break; } + if(browserIndex === -1) return; this.containerWindow = window; @@ -108,4 +111,4 @@ var ZoteroTab = new function() } window.addEventListener("load", function(e) { ZoteroTab.onLoad(e); }, false); -window.addEventListener("unload", function(e) { ZoteroTab.onUnload(e); }, false); \ No newline at end of file +window.addEventListener("unload", function(e) { ZoteroTab.onUnload(e); }, false);