1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/nfc/tests/marionette/test_nfc_enabled.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +MARIONETTE_TIMEOUT = 30000; 1.8 +MARIONETTE_HEAD_JS = 'head.js'; 1.9 + 1.10 +let nfc = window.navigator.mozNfc; 1.11 +function testEnableNFC() { 1.12 + log('Running \'testEnableNFC\''); 1.13 + let req = nfc.startPoll(); 1.14 + req.onsuccess = function () { 1.15 + ok(true); 1.16 + runNextTest(); 1.17 + }; 1.18 + req.onerror = function () { 1.19 + ok(false, "startPoll failed"); 1.20 + runNextTest(); 1.21 + }; 1.22 +} 1.23 + 1.24 +function testDisableNFC() { 1.25 + log('Running \'testDisableNFC\''); 1.26 + let req = nfc.powerOff(); 1.27 + req.onsuccess = function () { 1.28 + ok(true); 1.29 + runNextTest(); 1.30 + }; 1.31 + req.onerror = function () { 1.32 + ok(false, "powerOff failed"); 1.33 + runNextTest(); 1.34 + }; 1.35 +} 1.36 + 1.37 +function testStopPollNFC() { 1.38 + log('Running \'testStopPollNFC\''); 1.39 + let req = nfc.stopPoll(); 1.40 + req.onsuccess = function () { 1.41 + ok(true); 1.42 + runNextTest(); 1.43 + }; 1.44 + req.onerror = function () { 1.45 + ok(false, "stopPoll failed"); 1.46 + runNextTest(); 1.47 + }; 1.48 +} 1.49 + 1.50 +let tests = [ 1.51 + testEnableNFC, 1.52 + testStopPollNFC, 1.53 + testDisableNFC 1.54 +]; 1.55 + 1.56 +SpecialPowers.pushPermissions( 1.57 + [{'type': 'nfc-manager', 'allow': true, 'context': document}], 1.58 + runTests);