1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-23 02:42:41 +01:00

Firefox: remove evalInSandbox

Probably we won't eval plain text code, which makes it unnecessary, also
this way the validator on AMO won't complain about it.
This commit is contained in:
Deathamns 2015-01-27 13:31:17 +01:00
parent 637a75e6a0
commit f9109d7460
3 changed files with 21 additions and 26 deletions

View File

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

View File

@ -610,11 +610,11 @@ vAPI.tabs.injectScript = function(tabId, details, callback) {
return;
}
if ( details.file ) {
details.file = vAPI.getURL(details.file);
if ( typeof details.file !== 'string' ) {
return;
}
details.file = vAPI.getURL(details.file);
tab.linkedBrowser.messageManager.sendAsyncMessage(
location.host + ':broadcast',
JSON.stringify({

View File

@ -96,7 +96,7 @@ vAPI.messaging = {
return;
}
self.injectScript(details.file || details.code, !details.file);
self.injectScript(details.file);
}
};
},