Bug 970251 - Part 3: Marionette tests. r=dimi

This commit is contained in:
"allstars.chh" 2014-04-15 16:21:49 +08:00
parent 81aaa2bb6b
commit e214d09d1c

View File

@ -4,20 +4,53 @@
MARIONETTE_TIMEOUT = 30000; MARIONETTE_TIMEOUT = 30000;
MARIONETTE_HEAD_JS = 'head.js'; MARIONETTE_HEAD_JS = 'head.js';
let nfc = window.navigator.mozNfc;
function testEnableNFC() { function testEnableNFC() {
log('Running \'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() { function testDisableNFC() {
log('Running \'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 = [ let tests = [
testEnableNFC, testEnableNFC,
testStopPollNFC,
testDisableNFC testDisableNFC
]; ];
SpecialPowers.pushPermissions( SpecialPowers.pushPermissions(
[{'type': 'settings', 'allow': true, 'context': document}], runTests); [{'type': 'settings', 'allow': true, 'context': document},
{'type': 'nfc-manager', 'allow': true, 'context': document}],
runTests);