|
|
@ -183,14 +183,9 @@ const contentObserver = {
|
|
|
|
wantXHRConstructor: false
|
|
|
|
wantXHRConstructor: false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
sandbox.injectScript = function(script, evalCode) {
|
|
|
|
sandbox.injectScript = function(script) {
|
|
|
|
if ( evalCode ) {
|
|
|
|
Services.scriptloader.loadSubScript(script, sandbox);
|
|
|
|
Cu.evalInSandbox(script, this);
|
|
|
|
};
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Services.scriptloader.loadSubScript(script, this);
|
|
|
|
|
|
|
|
}.bind(sandbox);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
sandbox = win;
|
|
|
|
sandbox = win;
|
|
|
@ -200,43 +195,43 @@ const contentObserver = {
|
|
|
|
sandbox.sendAsyncMessage = messager.sendAsyncMessage;
|
|
|
|
sandbox.sendAsyncMessage = messager.sendAsyncMessage;
|
|
|
|
|
|
|
|
|
|
|
|
sandbox.addMessageListener = function(callback) {
|
|
|
|
sandbox.addMessageListener = function(callback) {
|
|
|
|
if ( this._messageListener_ ) {
|
|
|
|
if ( sandbox._messageListener_ ) {
|
|
|
|
this.removeMessageListener(
|
|
|
|
sandbox.removeMessageListener(
|
|
|
|
this._sandboxId_,
|
|
|
|
sandbox._sandboxId_,
|
|
|
|
this._messageListener_
|
|
|
|
sandbox._messageListener_
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._messageListener_ = function(message) {
|
|
|
|
sandbox._messageListener_ = function(message) {
|
|
|
|
callback(message.data);
|
|
|
|
callback(message.data);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
messager.addMessageListener(
|
|
|
|
messager.addMessageListener(
|
|
|
|
this._sandboxId_,
|
|
|
|
sandbox._sandboxId_,
|
|
|
|
this._messageListener_
|
|
|
|
sandbox._messageListener_
|
|
|
|
);
|
|
|
|
);
|
|
|
|
messager.addMessageListener(
|
|
|
|
messager.addMessageListener(
|
|
|
|
hostName + ':broadcast',
|
|
|
|
hostName + ':broadcast',
|
|
|
|
this._messageListener_
|
|
|
|
sandbox._messageListener_
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}.bind(sandbox);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
sandbox.removeMessageListener = function() {
|
|
|
|
sandbox.removeMessageListener = function() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
messager.removeMessageListener(
|
|
|
|
messager.removeMessageListener(
|
|
|
|
this._sandboxId_,
|
|
|
|
sandbox._sandboxId_,
|
|
|
|
this._messageListener_
|
|
|
|
sandbox._messageListener_
|
|
|
|
);
|
|
|
|
);
|
|
|
|
messager.removeMessageListener(
|
|
|
|
messager.removeMessageListener(
|
|
|
|
hostName + ':broadcast',
|
|
|
|
hostName + ':broadcast',
|
|
|
|
this._messageListener_
|
|
|
|
sandbox._messageListener_
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} catch (ex) {
|
|
|
|
} catch (ex) {
|
|
|
|
// It throws sometimes, mostly when the popup closes
|
|
|
|
// It throws sometimes, mostly when the popup closes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._messageListener_ = null;
|
|
|
|
sandbox._messageListener_ = null;
|
|
|
|
}.bind(sandbox);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return sandbox;
|
|
|
|
return sandbox;
|
|
|
|
},
|
|
|
|
},
|
|
|
|