Bug 1121840 - Use Cu.cloneInto for the result of NFCTag.transceive. r=dimi, a=bajaj
authorYoshi Huang <allstars.chh@mozilla.com>
Thu, 15 Jan 2015 14:55:25 +0800
changeset 232306 a652a4c0483578dc759a7bcb599bd57b2869c6f1
parent 232305 c7e49ae6384dcca769f8ed2a8e44a831941cf590
child 232307 016ef62fa791adff828680b402dcc99af6b8e35f
push id30
push userryanvm@gmail.com
push dateWed, 21 Jan 2015 01:09:36 +0000
treeherdermozilla-b2g37_v2_2@7762046d3296 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdimi, bajaj
bugs1121840
milestone37.0a2
Bug 1121840 - Use Cu.cloneInto for the result of NFCTag.transceive. r=dimi, a=bajaj
dom/nfc/NfcContentHelper.js
dom/nfc/nsNfc.js
--- a/dom/nfc/NfcContentHelper.js
+++ b/dom/nfc/NfcContentHelper.js
@@ -350,17 +350,17 @@ NfcContentHelper.prototype = {
     switch (name) {
       case NFC.SETTING_NFC_DEBUG:
         DEBUG = result;
         updateDebug();
         break;
     }
   },
 
-  handleGeneralResponse: function handleReadNDEFResponse(result) {
+  handleGeneralResponse: function handleGeneralResponse(result) {
     let requestId = result.requestId;
     let callback = this._requestMap[requestId];
     if (!callback) {
       debug("not firing message " + result.type + " for id: " + requestId);
       return;
     }
     delete this._requestMap[requestId];
 
--- a/dom/nfc/nsNfc.js
+++ b/dom/nfc/nsNfc.js
@@ -20,22 +20,24 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this,
                                    "appsService",
                                    "@mozilla.org/AppsService;1",
                                    "nsIAppsService");
 
 function NfcCallback(aWindow) {
+  this._window = aWindow;
   this.initDOMRequestHelper(aWindow, null);
   this._createPromise();
 }
 NfcCallback.prototype = {
   __proto__: DOMRequestIpcHelper.prototype,
 
+  _window: null,
   promise: null,
   _requestId: null,
 
   _createPromise: function _createPromise() {
     this.promise = this.createPromise((aResolve, aReject) => {
       this._requestId = btoa(this.getPromiseResolverId({
         resolve: aResolve,
         reject: aReject
@@ -75,17 +77,17 @@ NfcCallback.prototype = {
   },
 
   notifySuccessWithByteArray: function notifySuccessWithByteArray(aArray) {
     let resolver = this.takePromiseResolver(atob(this._requestId));
     if (!resolver) {
       debug("can not find promise resolver for id: " + this._requestId);
       return;
     }
-    resolver.resolve(aArray);
+    resolver.resolve(Cu.cloneInto(aArray, this._window));
   },
 
   notifyError: function notifyError(aErrorMsg) {
     let resolver = this.takePromiseResolver(atob(this._requestId));
     if (!resolver) {
       debug("can not find promise resolver for id: " + this._requestId +
            ", errormsg: " + aErrorMsg);
       return;