Backed out changeset b8c53e689955 (bug 1042651) because it depends on the patch from bug 1046554 which was backed out.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 06 Aug 2014 15:37:54 -0400
changeset 219771 3422b5ff6a475b2497feeaaaedb2d8affd55a4b7
parent 219770 8dc536903cfe4dcabd60cb8c72b6e052d6d3a94a
child 219772 e5e3ac96acc9663e3d699c50b71c55bc57932aef
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1042651, 1046554
milestone34.0a1
backs outb8c53e689955c072134740b44fcf70dd7ce745c8
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
Backed out changeset b8c53e689955 (bug 1042651) because it depends on the patch from bug 1046554 which was backed out.
dom/nfc/nsNfc.js
dom/nfc/tests/marionette/test_nfc_peer.js
dom/webidl/MozNFC.webidl
--- a/dom/nfc/nsNfc.js
+++ b/dom/nfc/nsNfc.js
@@ -195,22 +195,24 @@ mozNfc.prototype = {
   },
 
   getNFCTag: function getNFCTag(sessionToken) {
     let obj = new MozNFCTag();
     obj.initialize(this._window, sessionToken);
     if (this._nfcContentHelper.setSessionToken(sessionToken)) {
       return this._window.MozNFCTag._create(this._window, obj);
     }
-    return null;
+    throw new Error("Unable to create NFCTag object, Reason:  Bad SessionToken " +
+                     sessionToken);
   },
 
   getNFCPeer: function getNFCPeer(sessionToken) {
     if (!sessionToken || !this._nfcContentHelper.setSessionToken(sessionToken)) {
-      return null;
+      throw new Error("Unable to create NFCPeer object, Reason:  Bad SessionToken " +
+                      sessionToken);
     }
 
     if (!this.nfcObject) {
       let obj = new MozNFCPeer();
       obj.initialize(this._window, sessionToken);
       this.nfcObject = obj;
       this.nfcObject.contentObject = this._window.MozNFCPeer._create(this._window, obj);
     }
--- a/dom/nfc/tests/marionette/test_nfc_peer.js
+++ b/dom/nfc/tests/marionette/test_nfc_peer.js
@@ -80,16 +80,28 @@ function testPeerReady() {
 
 function testCheckP2PRegFailure() {
   window.navigator.mozSetMessageHandler(
     "nfc-manager-tech-discovered", handleTechnologyDiscoveredRE0ForP2PRegFailure);
 
   toggleNFC(true).then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0));
 }
 
+function testCheckNfcPeerObjForInvalidToken() {
+  try {
+    // Use a'fakeSessionToken'
+    let peer = nfc.getNFCPeer("fakeSessionToken");
+    ok(false, "Should not get a NFCPeer object.");
+  } catch (ex) {
+    ok(true, "Exception expected");
+  }
+
+  toggleNFC(false).then(runNextTest);
+}
+
 function testPeerLostShouldNotBeCalled() {
   nfc.onpeerlost = function () {
     ok(false, "onpeerlost shouldn't be called");
   };
 
   toggleNFC(true)
     .then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0))
     .then(NCI.deactivate)
@@ -134,38 +146,19 @@ function testPeerShouldThrow() {
   } catch (e) {
     ok(true, "Exception expected");
   }
 
   nfc.onpeerready = null;
   toggleNFC(false).then(runNextTest);
 }
 
-function testPeerInvalidToken() {
-  let peer = nfc.getNFCPeer("fakeSessionToken");
-  is(peer, null, "NFCPeer should be null on wrong session token");
-
-  runNextTest();
-}
-
-/**
- * Added for completeness in Bug 1042651,
- * TODO: remove once Bug 963531 lands
- */
-function testTagInvalidToken() {
-  let tag = nfc.getNFCTag("fakeSessionToken");
-  is(tag, null, "NFCTag should be null on wrong session token");
-
-  runNextTest();
-}
-
 let tests = [
   testPeerReady,
   testCheckP2PRegFailure,
+  testCheckNfcPeerObjForInvalidToken,
   testPeerLostShouldNotBeCalled,
-  testPeerShouldThrow,
-  testPeerInvalidToken,
-  testTagInvalidToken
+  testPeerShouldThrow
 ];
 
 SpecialPowers.pushPermissions(
   [{"type": "nfc-manager", "allow": true, context: document},
    {"type": "nfc-write", "allow": true, context: document}], runTests);
--- a/dom/webidl/MozNFC.webidl
+++ b/dom/webidl/MozNFC.webidl
@@ -41,25 +41,20 @@ interface MozNFCManager {
     */
    DOMRequest powerOff();
 };
 
 [JSImplementation="@mozilla.org/navigatorNfc;1",
  NavigatorProperty="mozNfc",
  Func="Navigator::HasNFCSupport"]
 interface MozNFC : EventTarget {
-   /**
-    * Returns MozNFCTag object or null in case of invalid sessionToken
-    */
-   MozNFCTag? getNFCTag(DOMString sessionToken);
-
-   /**
-    * Returns MozNFCPeer object or null in case of invalid sessionToken
-    */
-   MozNFCPeer? getNFCPeer(DOMString sessionToken);
+   [Throws]
+   MozNFCTag getNFCTag(DOMString sessionId);
+   [Throws]
+   MozNFCPeer getNFCPeer(DOMString sessionId);
 
    /**
     * This event will be fired when another NFCPeer is detected, and user confirms
     * to share data to the NFCPeer object by calling mozNFC.notifyUserAcceptedP2P.
     * The event will be type of NFCPeerEvent.
     */
    [CheckPermissions="nfc-write"]
    attribute EventHandler onpeerready;