diff options
author | Deathamns <deathamns@gmail.com> | 2014-12-20 17:43:10 +0100 |
---|---|---|
committer | Deathamns <deathamns@gmail.com> | 2015-01-13 07:29:39 +0100 |
commit | 7ade0ec7e85d37ca2cde104912127b06c4498379 (patch) | |
tree | 8f42fc577d26c307e329113ba4789a14aab22a9e | |
parent | 5c2af95c734c388717d4a7843b0ea9455293041f (diff) | |
download | uBlock-7ade0ec7e85d37ca2cde104912127b06c4498379.zip uBlock-7ade0ec7e85d37ca2cde104912127b06c4498379.tar.gz uBlock-7ade0ec7e85d37ca2cde104912127b06c4498379.tar.bz2 |
Firefox: better way to get the messageManager
-rw-r--r-- | platform/firefox/frameModule.js | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index 8223817..2afc888 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -28,12 +28,7 @@ this.EXPORTED_SYMBOLS = ['contentPolicy', 'docObserver']; const {interfaces: Ci, utils: Cu} = Components; - -let appName; - -try { throw new Error; } catch (ex) { - appName = ex.fileName.match(/:\/\/([^\/]+)/)[1]; -} +const appName = __URI__.match(/:\/\/([^\/]+)/)[1]; Cu['import']('resource://gre/modules/Services.jsm'); Cu['import']('resource://gre/modules/XPCOMUtils.jsm'); @@ -41,25 +36,11 @@ Cu['import']('resource://gre/modules/XPCOMUtils.jsm'); /******************************************************************************/ -let getMessager = function(win) { - try { - // e10s - return win - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .rootTreeItem - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIContentFrameMessageManager); - } catch (ex) { - return win - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIContentFrameMessageManager); - } -}; +const getMessager = win => + win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDocShell) + .sameTypeRootTreeItem.QueryInterface(Ci.nsIDocShell) + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIContentFrameMessageManager); /******************************************************************************/ |