aboutsummaryrefslogtreecommitdiffstats
path: root/platform/firefox/frameModule.js
diff options
context:
space:
mode:
Diffstat (limited to 'platform/firefox/frameModule.js')
-rw-r--r--platform/firefox/frameModule.js47
1 files changed, 36 insertions, 11 deletions
diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js
index a11720e..37de2b5 100644
--- a/platform/firefox/frameModule.js
+++ b/platform/firefox/frameModule.js
@@ -23,6 +23,7 @@
/******************************************************************************/
+// https://github.com/gorhill/uBlock/issues/800
this.EXPORTED_SYMBOLS = ['contentObserver', 'LocationChangeListener'];
const {interfaces: Ci, utils: Cu} = Components;
@@ -30,6 +31,7 @@ const {Services} = Cu.import('resource://gre/modules/Services.jsm', null);
const {XPCOMUtils} = Cu.import('resource://gre/modules/XPCOMUtils.jsm', null);
const hostName = Services.io.newURI(Components.stack.filename, null, null).host;
+const rpcEmitterName = hostName + ':child-process-message';
//Cu.import('resource://gre/modules/devtools/Console.jsm');
@@ -61,7 +63,7 @@ const getMessageManager = function(win) {
/******************************************************************************/
-const contentObserver = {
+var contentObserver = {
classDescription: 'content-policy for ' + hostName,
classID: Components.ID('{7afbd130-cbaf-46c2-b944-f5d24305f484}'),
contractID: '@' + hostName + '/content-policy;1',
@@ -239,9 +241,25 @@ const contentObserver = {
wantXHRConstructor: false
});
+ if ( Services.cpmm ) {
+ sandbox.rpc = function(details) {
+ var svc = Services;
+ if ( svc === undefined ) { return; }
+ var cpmm = svc.cpmm;
+ if ( !cpmm ) { return; }
+ var r = cpmm.sendSyncMessage(rpcEmitterName, details);
+ if ( Array.isArray(r) ) {
+ return r[0];
+ }
+ };
+ } else {
+ sandbox.rpc = function() {};
+ }
+
sandbox.injectScript = function(script) {
- if ( Services !== undefined ) {
- Services.scriptloader.loadSubScript(script, sandbox);
+ var svc = Services;
+ if ( svc !== undefined ) {
+ svc.scriptloader.loadSubScript(script, sandbox);
} else {
// Sandbox appears void.
// I've seen this happens, need to investigate why.
@@ -258,9 +276,10 @@ const contentObserver = {
sandbox.removeMessageListener();
sandbox.addMessageListener =
sandbox.injectScript =
+ sandbox.outerShutdown =
sandbox.removeMessageListener =
- sandbox.sendAsyncMessage =
- sandbox.outerShutdown = function(){};
+ sandbox.rpc =
+ sandbox.sendAsyncMessage = function(){};
sandbox.vAPI = {};
messager = null;
};
@@ -405,20 +424,26 @@ const contentObserver = {
const locationChangedMessageName = hostName + ':locationChanged';
-const LocationChangeListener = function(docShell) {
+var LocationChangeListener = function(docShell) {
if ( !docShell ) {
return;
}
var requestor = docShell.QueryInterface(Ci.nsIInterfaceRequestor);
var ds = requestor.getInterface(Ci.nsIWebProgress);
+ if ( !ds ) {
+ return;
+ }
var mm = requestor.getInterface(Ci.nsIContentFrameMessageManager);
-
- if ( ds && mm && typeof mm.sendAsyncMessage === 'function' ) {
- this.docShell = ds;
- this.messageManager = mm;
- ds.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_LOCATION);
+ if ( !mm ) {
+ return;
+ }
+ if ( typeof mm.sendAsyncMessage !== 'function' ) {
+ return;
}
+ this.docShell = ds;
+ this.messageManager = mm;
+ ds.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_LOCATION);
};
LocationChangeListener.prototype.QueryInterface = XPCOMUtils.generateQI([