зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1019668 - Part 1: Not adding errorMsg if status property undefined, test cases for changes, r=allstars.chh
This commit is contained in:
Родитель
30850aa738
Коммит
d409ae1c10
|
@ -6,7 +6,7 @@
|
|||
/* globals log, is, ok, runTests, toggleNFC, runNextTest,
|
||||
SpecialPowers, nfc, enableRE0, MozNDEFRecord */
|
||||
|
||||
const MARIONETTE_TIMEOUT = 30000;
|
||||
const MARIONETTE_TIMEOUT = 60000;
|
||||
const MARIONETTE_HEAD_JS = 'head.js';
|
||||
|
||||
const MANIFEST_URL = 'app://system.gaiamobile.org/manifest.webapp';
|
||||
|
@ -76,6 +76,21 @@ function testNfcConnectError() {
|
|||
.catch(handleRejectedPromise);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables nfc and RE0, registers tech-discovered msg handler, once it's
|
||||
* fired set tech-lost handler and disables nfc. In both handlers checks
|
||||
* if error message is not present.
|
||||
*/
|
||||
function testNoErrorInTechMsg() {
|
||||
log('testNoErrorInTechMsg');
|
||||
toggleNFC(true)
|
||||
.then(enableRE0)
|
||||
.then(setTechDiscoveredHandler)
|
||||
.then(setAndFireTechLostHandler)
|
||||
.then(endTest)
|
||||
.catch(handleRejectedPromise);
|
||||
}
|
||||
|
||||
function endTest() {
|
||||
nfcPeers = [];
|
||||
sessionTokens = [];
|
||||
|
@ -155,10 +170,47 @@ function connectToNFCTagExpectError(sessionToken, tech, errorMsg) {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
function setTechDiscoveredHandler() {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let techDiscoveredHandler = function(msg) {
|
||||
ok('Message handler for nfc-manager-tech-discovered');
|
||||
is(msg.type, 'techDiscovered');
|
||||
is(msg.errorMsg, undefined, 'Should not get error msg in tech discovered');
|
||||
|
||||
window.navigator.mozSetMessageHandler('nfc-manager-tech-discovered', null);
|
||||
deferred.resolve();
|
||||
};
|
||||
|
||||
window.navigator.mozSetMessageHandler('nfc-manager-tech-discovered',
|
||||
techDiscoveredHandler);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function setAndFireTechLostHandler() {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let techLostHandler = function(msg) {
|
||||
ok('Message handler for nfc-manager-tech-lost');
|
||||
is(msg.type, 'techLost');
|
||||
is(msg.errorMsg, undefined, 'Should not get error msg in tech lost');
|
||||
|
||||
window.navigator.mozSetMessageHandler('nfc-manager-tech-lost', null);
|
||||
deferred.resolve();
|
||||
};
|
||||
|
||||
window.navigator.mozSetMessageHandler('nfc-manager-tech-lost',
|
||||
techLostHandler);
|
||||
// TODO should be refactored once Bug 1023079 lands
|
||||
toggleNFC(false);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
let tests = [
|
||||
testNfcNotEnabledError,
|
||||
testNfcBadSessionIdError,
|
||||
testNfcConnectError
|
||||
testNfcConnectError,
|
||||
testNoErrorInTechMsg
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -494,7 +494,7 @@ Nfc.prototype = {
|
|||
debug("Received message from NFC worker: " + JSON.stringify(message));
|
||||
|
||||
// mapping error code to error message
|
||||
if(message.status !== NFC.NFC_SUCCESS) {
|
||||
if (message.status !== undefined && message.status !== NFC.NFC_SUCCESS) {
|
||||
message.errorMsg = this.getErrorMessage(message.status);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче