Bug 1121840 - Use Cu.cloneInto for the result of NFCTag.transceive. r=dimi
authorYoshi Huang <allstars.chh@mozilla.com>
Thu, 15 Jan 2015 14:55:25 +0800
changeset 224191 47e905a0b0f5afaeb472b14e7659a7cd4b59e640
parent 224190 e0b32ca5a9672e282b777bf36460d68508f109d0
child 224192 181a72bbc0d1ddad9ac1016cd2384b21147cf519
push id54150
push usercbook@mozilla.com
push dateFri, 16 Jan 2015 14:14:56 +0000
treeherdermozilla-inbound@ac6623427298 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdimi
bugs1121840
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1121840 - Use Cu.cloneInto for the result of NFCTag.transceive. r=dimi
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;