Bug 1078378 - Replace the array instance used by `emitSync` with one from the content's sandbox. r=Mossop
authorZER0 <zer0.kaos@gmail.com>
Mon, 06 Oct 2014 13:56:18 -0700
changeset 209067 421486270287878ecc350a94d9ff4d29b6798fea
parent 209066 b56f9bccea925bbf1189b3e218599eebfd094596
child 209068 5578b160f514fcbfb782c980fee483fa6e410c95
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersMossop
bugs1078378
milestone35.0a1
Bug 1078378 - Replace the array instance used by `emitSync` with one from the content's sandbox. r=Mossop
addon-sdk/source/lib/sdk/content/sandbox.js
--- a/addon-sdk/source/lib/sdk/content/sandbox.js
+++ b/addon-sdk/source/lib/sdk/content/sandbox.js
@@ -69,17 +69,20 @@ const WorkerSandbox = Class({
 
   /**
    * Synchronous version of `emit`.
    * /!\ Should only be used when it is strictly mandatory /!\
    *     Doesn't ensure passing only JSON values.
    *     Mainly used by context-menu in order to avoid breaking it.
    */
   emitSync: function emitSync(...args) {
-    return emitToContent(this, args);
+    // because the arguments could be also non JSONable values,
+    // we need to ensure the array instance is created from
+    // the content's sandbox
+    return emitToContent(this, new modelFor(this).sandbox.Array(...args));
   },
 
   /**
    * Configures sandbox and loads content scripts into it.
    * @param {Worker} worker
    *    content worker
    */
   initialize: function WorkerSandbox(worker, window) {