|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 MARIONETTE_TIMEOUT = 30000; |
|
5 MARIONETTE_HEAD_JS = 'head.js'; |
|
6 |
|
7 let nfc = window.navigator.mozNfc; |
|
8 function testEnableNFC() { |
|
9 log('Running \'testEnableNFC\''); |
|
10 let req = nfc.startPoll(); |
|
11 req.onsuccess = function () { |
|
12 ok(true); |
|
13 runNextTest(); |
|
14 }; |
|
15 req.onerror = function () { |
|
16 ok(false, "startPoll failed"); |
|
17 runNextTest(); |
|
18 }; |
|
19 } |
|
20 |
|
21 function testDisableNFC() { |
|
22 log('Running \'testDisableNFC\''); |
|
23 let req = nfc.powerOff(); |
|
24 req.onsuccess = function () { |
|
25 ok(true); |
|
26 runNextTest(); |
|
27 }; |
|
28 req.onerror = function () { |
|
29 ok(false, "powerOff failed"); |
|
30 runNextTest(); |
|
31 }; |
|
32 } |
|
33 |
|
34 function testStopPollNFC() { |
|
35 log('Running \'testStopPollNFC\''); |
|
36 let req = nfc.stopPoll(); |
|
37 req.onsuccess = function () { |
|
38 ok(true); |
|
39 runNextTest(); |
|
40 }; |
|
41 req.onerror = function () { |
|
42 ok(false, "stopPoll failed"); |
|
43 runNextTest(); |
|
44 }; |
|
45 } |
|
46 |
|
47 let tests = [ |
|
48 testEnableNFC, |
|
49 testStopPollNFC, |
|
50 testDisableNFC |
|
51 ]; |
|
52 |
|
53 SpecialPowers.pushPermissions( |
|
54 [{'type': 'nfc-manager', 'allow': true, 'context': document}], |
|
55 runTests); |