diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index a360d7168..98338e32f 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -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; }, diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 39207576a..9fec753d5 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -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({ diff --git a/platform/firefox/vapi-client.js b/platform/firefox/vapi-client.js index d11a84f9e..58bb110ca 100644 --- a/platform/firefox/vapi-client.js +++ b/platform/firefox/vapi-client.js @@ -96,7 +96,7 @@ vAPI.messaging = { return; } - self.injectScript(details.file || details.code, !details.file); + self.injectScript(details.file); } }; },