From c73704ba483c9e1c799b24bb451cba5ae43dcf73 Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 28 May 2015 14:49:36 -0400 Subject: [PATCH] code review --- platform/firefox/frameModule.js | 9 +++++++-- platform/firefox/frameScript.js | 11 ++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index db7ce6f41..2e9c52ba8 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -218,7 +218,13 @@ const contentObserver = { }); sandbox.injectScript = function(script) { - Services.scriptloader.loadSubScript(script, sandbox); + if ( Services !== undefined ) { + Services.scriptloader.loadSubScript(script, sandbox); + } else { + // Sandbox appears void. + // I've seen this happens, need to investigate why. + + } }; } else { @@ -358,7 +364,6 @@ LocationChangeListener.prototype.onLocationChange = function(webProgress, reques if ( !webProgress.isTopLevel ) { return; } - this.messageManager.sendAsyncMessage(locationChangedMessageName, { url: location.asciiSpec, flags: flags, diff --git a/platform/firefox/frameScript.js b/platform/firefox/frameScript.js index e8c3cba41..388c7913b 100644 --- a/platform/firefox/frameScript.js +++ b/platform/firefox/frameScript.js @@ -56,7 +56,16 @@ let onLoadCompleted = function() { addMessageListener('ublock-load-completed', onLoadCompleted); -locationChangeListener = new LocationChangeListener(docShell); +if ( docShell ) { + let Ci = Components.interfaces; + let wp = docShell.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebProgress); + let dw = wp.DOMWindow; + + if ( dw === dw.top ) { + locationChangeListener = new LocationChangeListener(docShell); + } +} /******************************************************************************/