diff --git a/dom/nfc/tests/marionette/head.js b/dom/nfc/tests/marionette/head.js index 5223e9d6c176..0443dd25ca24 100644 --- a/dom/nfc/tests/marionette/head.js +++ b/dom/nfc/tests/marionette/head.js @@ -126,8 +126,9 @@ let NCI = (function() { let TAG = (function() { function setData(re, flag, tnf, type, payload) { let deferred = Promise.defer(); + let tnfNum = NDEF.getTNFNum(tnf); let cmd = "nfc tag set " + re + - " [" + flag + "," + tnf + "," + type + ",," + payload + "]"; + " [" + flag + "," + tnfNum + "," + type + ",," + payload + "]"; emulator.run(cmd, function(result) { is(result.pop(), "OK", "set NDEF data of tag" + re); @@ -156,8 +157,9 @@ let TAG = (function() { let SNEP = (function() { function put(dsap, ssap, flags, tnf, type, id, payload) { let deferred = Promise.defer(); + let tnfNum = NDEF.getTNFNum(tnf); let cmd = "nfc snep put " + dsap + " " + ssap + " [" + flags + "," + - tnf + "," + + tnfNum + "," + type + "," + id + "," + payload + "]"; @@ -245,7 +247,18 @@ function runTests() { } const NDEF = { - TNF_WELL_KNOWN: 1, + TNF_WELL_KNOWN: "well-known", + + tnfValues: ["empty", "well-known", "media-type", "absolute-uri", "external", + "unknown", "unchanged", "reserved"], + + getTNFNum: function (tnfString) { + return this.tnfValues.indexOf(tnfString); + }, + + getTNFString: function(tnfNum) { + return this.tnfValues[tnfNum]; + }, // compares two NDEF messages compare: function(ndef1, ndef2) { @@ -290,7 +303,7 @@ const NDEF = { let type = NfcUtils.fromUTF8(this.atob(value.type)); let id = NfcUtils.fromUTF8(this.atob(value.id)); let payload = NfcUtils.fromUTF8(this.atob(value.payload)); - return new MozNDEFRecord({tnf: value.tnf, type: type, id: id, payload: payload}); + return new MozNDEFRecord({tnf: NDEF.getTNFString(value.tnf), type: type, id: id, payload: payload}); }, window); return ndef; } diff --git a/dom/nfc/tests/marionette/test_ndef.js b/dom/nfc/tests/marionette/test_ndef.js index b17d11a45ca0..1ca59ca637ea 100644 --- a/dom/nfc/tests/marionette/test_ndef.js +++ b/dom/nfc/tests/marionette/test_ndef.js @@ -8,7 +8,7 @@ function testConstructNDEF() { try { // omit type, id and payload. let r = new MozNDEFRecord(); - is(r.tnf, 0, "r.tnf should be 0"); + is(r.tnf, "empty", "r.tnf should be 'empty'"); is(r.type, null, "r.type should be null"); is(r.id, null, "r.id should be null"); is(r.payload, null, "r.payload should be null"); diff --git a/dom/nfc/tests/marionette/test_nfc_error_messages.js b/dom/nfc/tests/marionette/test_nfc_error_messages.js index 75ad583486da..4a91f2c758ee 100644 --- a/dom/nfc/tests/marionette/test_nfc_error_messages.js +++ b/dom/nfc/tests/marionette/test_nfc_error_messages.js @@ -10,7 +10,7 @@ const MARIONETTE_TIMEOUT = 60000; const MARIONETTE_HEAD_JS = 'head.js'; const MANIFEST_URL = 'app://system.gaiamobile.org/manifest.webapp'; -const NDEF_MESSAGE = [new MozNDEFRecord({tnf: 0x01, +const NDEF_MESSAGE = [new MozNDEFRecord({tnf: "well-known", type: new Uint8Array(0x84), payload: new Uint8Array(0x20)})];