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_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);