code review

This commit is contained in:
gorhill 2015-05-28 14:49:36 -04:00
parent c285ace7d8
commit c73704ba48
2 changed files with 17 additions and 3 deletions

View file

@ -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,

View file

@ -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);
}
}
/******************************************************************************/