Bug 1084385 - Use exportFunction for emitToChrome. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Sat, 18 Oct 2014 11:02:08 +0200
changeset 211104 32182ec68d76d876305935ee9e733e984a31fde6
parent 211103 acce1a807efb86cc882d2215a57ef9b1892ff983
child 211105 bac6e8c4efab449dacec003ced64b25dfa86ab33
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersgabor
bugs1084385
milestone36.0a1
Bug 1084385 - Use exportFunction for emitToChrome. r=gabor
addon-sdk/source/lib/sdk/content/sandbox.js
addon-sdk/source/lib/sdk/deprecated/traits-worker.js
--- a/addon-sdk/source/lib/sdk/content/sandbox.js
+++ b/addon-sdk/source/lib/sdk/content/sandbox.js
@@ -171,17 +171,17 @@ const WorkerSandbox = Class({
     let options = 'contentScriptOptions' in worker ?
       JSON.stringify(worker.contentScriptOptions) :
       undefined;
 
     // Then call `inject` method and communicate with this script
     // by trading two methods that allow to send events to the other side:
     //   - `onEvent` called by content script
     //   - `result.emitToContent` called by addon script
-    let onEvent = onContentEvent.bind(null, this);
+    let onEvent = Cu.exportFunction(onContentEvent.bind(null, this), ContentWorker);
     let chromeAPI = createChromeAPI(ContentWorker);
     let result = Cu.waiveXrays(ContentWorker).inject(content, chromeAPI, onEvent, options);
 
     // Merge `emitToContent` into our private model of the
     // WorkerSandbox so we can communicate with content script
     model.emitToContent = result;
 
     let console = new PlainTextConsole(null, getInnerId(window));
--- a/addon-sdk/source/lib/sdk/deprecated/traits-worker.js
+++ b/addon-sdk/source/lib/sdk/deprecated/traits-worker.js
@@ -190,17 +190,17 @@ const WorkerSandbox = EventEmitter.compo
         setInterval: timer.setInterval.bind(timer),
         clearTimeout: timer.clearTimeout.bind(timer),
         clearInterval: timer.clearInterval.bind(timer),
       },
       sandbox: {
         evaluate: evaluate,
       },
     }, ContentWorker, {cloneFunctions: true});
-    let onEvent = this._onContentEvent.bind(this);
+    let onEvent = Cu.exportFunction(this._onContentEvent.bind(this), ContentWorker);
     let result = Cu.waiveXrays(ContentWorker).inject(content, chromeAPI, onEvent, options);
     this._emitToContent = result;
 
     // Handle messages send by this script:
     let self = this;
     // console.xxx calls
     this.on("console", function consoleListener(kind) {
       console[kind].apply(console, Array.slice(arguments, 1));