Bug 933595 - Part 2: Adding promise to toggleNFC, adding enableRE0. r=allstars.chh

This commit is contained in:
Krzysztof Mioduszewski 2014-05-22 16:33:45 +02:00
parent 3533cdf74a
commit fb2871d672

View File

@ -37,7 +37,7 @@ let emulator = (function() {
}());
function toggleNFC(enabled, callback) {
isnot(callback, null);
let deferred = Promise.defer();
let req;
if (enabled) {
@ -47,13 +47,32 @@ function toggleNFC(enabled, callback) {
}
req.onsuccess = function() {
callback();
if(callback) {
callback();
}
deferred.resolve();
};
req.onerror = function() {
ok(false, 'operation failed, error ' + req.error.name);
deferred.reject();
finish();
};
return deferred.promise;
}
function enableRE0() {
let deferred = Promise.defer();
let cmd = 'nfc nci rf_intf_activated_ntf 0';
emulator.run(cmd, function(result) {
is(result.pop(), 'OK', 'check activation of RE0');
deferred.resolve();
});
return deferred.promise;
}
function cleanUp() {