Bug 1076708 - [Loop] Close the verification code windows cause the app trying to authenticate infinitely. r=spenrose

This commit is contained in:
Fernando Jiménez 2014-10-10 14:38:51 +02:00
parent 0366e6ca44
commit 5bf02f6edf
2 changed files with 55 additions and 4 deletions

View File

@ -417,7 +417,7 @@ this.MobileIdentityManager = {
onUICancel: function() {
log.debug("UI cancel");
if (this.activeVerificationFlow) {
this.activeVerificationFlow.cleanup(true);
this.rejectVerification();
}
},
@ -467,7 +467,7 @@ this.MobileIdentityManager = {
}
this.activeVerificationDeferred.reject(aReason);
this.activeVerificationDeferred = null;
this.cleanupVerification(true);
this.cleanupVerification(true /* unregister */);
},
resolveVerification: function(aResult) {
@ -479,11 +479,11 @@ this.MobileIdentityManager = {
this.cleanupVerification();
},
cleanupVerification: function() {
cleanupVerification: function(aUnregister = false) {
if (!this.activeVerificationFlow) {
return;
}
this.activeVerificationFlow.cleanup();
this.activeVerificationFlow.cleanup(aUnregister);
this.activeVerificationFlow = null;
},

View File

@ -1459,3 +1459,54 @@ add_test(function() {
}
});
});
add_test(function() {
do_print("= Cancel verification flow =");
do_register_cleanup(cleanup);
do_test_pending();
let _sessionToken = Date.now();
let ui = new MockUi();
ui.verificationCodePrompt = function() {
MobileIdentityManager.onUICancel();
};
MobileIdentityManager.ui = ui;
let credStore = new MockCredStore();
MobileIdentityManager.credStore = credStore;
let client = new MockClient();
MobileIdentityManager.client = client;
let promiseId = Date.now();
let mm = {
sendAsyncMessage: function(aMsg, aData) {
do_print("sendAsyncMessage " + aMsg + " - " + JSON.stringify(aData));
// Check result.
do_check_eq(aMsg, GET_ASSERTION_RETURN_KO);
do_check_eq(typeof aData, "object");
do_check_eq(aData.promiseId, promiseId);
do_check_eq(aData.error, DIALOG_CLOSED_BY_USER);
do_test_finished();
run_next_test();
}
};
addPermission(Ci.nsIPermissionManager.ALLOW_ACTION);
MobileIdentityManager.receiveMessage({
name: GET_ASSERTION_IPC_MSG,
principal: PRINCIPAL,
target: mm,
json: {
promiseId: promiseId,
options: {}
}
});
});