From e214d09d1c3b503d54072e3faa5b7198d7c37301 Mon Sep 17 00:00:00 2001 From: "\"allstars.chh\"" Date: Tue, 15 Apr 2014 16:21:49 +0800 Subject: [PATCH] Bug 970251 - Part 3: Marionette tests. r=dimi --- dom/nfc/tests/marionette/test_nfc_enabled.js | 39 ++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/dom/nfc/tests/marionette/test_nfc_enabled.js b/dom/nfc/tests/marionette/test_nfc_enabled.js index 8ef07a46be0..7c31cf6c4ff 100644 --- a/dom/nfc/tests/marionette/test_nfc_enabled.js +++ b/dom/nfc/tests/marionette/test_nfc_enabled.js @@ -4,20 +4,53 @@ MARIONETTE_TIMEOUT = 30000; MARIONETTE_HEAD_JS = 'head.js'; +let nfc = window.navigator.mozNfc; function testEnableNFC() { log('Running \'testEnableNFC\''); - toggleNFC(true, runNextTest); + let req = nfc.startPoll(); + req.onsuccess = function () { + ok(true); + runNextTest(); + }; + req.onerror = function () { + ok(false, "startPoll failed"); + runNextTest(); + }; } function testDisableNFC() { log('Running \'testDisableNFC\''); - toggleNFC(false, runNextTest); + let req = nfc.powerOff(); + req.onsuccess = function () { + ok(true); + runNextTest(); + }; + req.onerror = function () { + ok(false, "powerOff failed"); + runNextTest(); + }; +} + +function testStopPollNFC() { + log('Running \'testStopPollNFC\''); + let req = nfc.stopPoll(); + req.onsuccess = function () { + ok(true); + runNextTest(); + }; + req.onerror = function () { + ok(false, "stopPoll failed"); + runNextTest(); + }; } let tests = [ testEnableNFC, + testStopPollNFC, testDisableNFC ]; SpecialPowers.pushPermissions( - [{'type': 'settings', 'allow': true, 'context': document}], runTests); + [{'type': 'settings', 'allow': true, 'context': document}, + {'type': 'nfc-manager', 'allow': true, 'context': document}], + runTests);