From 12efce878659e8b915e1b02e07f131872dfa7710 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 19 May 2011 22:48:26 +0000 Subject: [PATCH] A better way of getting browser and window in proxy.js --- chrome/content/zotero/xpcom/proxy.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/xpcom/proxy.js b/chrome/content/zotero/xpcom/proxy.js index e3b764198..b684362a5 100644 --- a/chrome/content/zotero/xpcom/proxy.js +++ b/chrome/content/zotero/xpcom/proxy.js @@ -398,16 +398,9 @@ Zotero.Proxies = new function() { * @return {Array} Array containing a browser object and a DOM window object */ function _getBrowserAndWindow(notificationCallbacks) { - try { - var pageDOMDocument = notificationCallbacks.getInterface(Components.interfaces.nsIDOMWindow).top.document; - if(!pageDOMDocument) return false; - var enumerator = windowMediator.getZOrderDOMWindowEnumerator("navigator:browser", true); - while(enumerator.hasMoreElements()) { - var window = enumerator.getNext(); - browser = window.gBrowser.getBrowserForDocument(pageDOMDocument); - if(browser) break; - } - } catch(e) {} + var browser = notificationCallbacks.getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShell).chromeEventHandler; + var window = browser.ownerDocument.defaultView; return [browser, window]; }