Bug 1076708 - [Loop] Close the verification code windows cause the app trying to authenticate infinitely. r=spenrose
--- a/services/mobileid/MobileIdentityManager.jsm
+++ b/services/mobileid/MobileIdentityManager.jsm
@@ -412,17 +412,17 @@ this.MobileIdentityManager = {
/*********************************************************
* UI callbacks
********************************************************/
onUICancel: function() {
log.debug("UI cancel");
if (this.activeVerificationFlow) {
- this.activeVerificationFlow.cleanup(true);
+ this.rejectVerification();
}
},
onUIResendCode: function() {
log.debug("UI resend code");
if (!this.activeVerificationFlow) {
return;
}
@@ -462,33 +462,33 @@ this.MobileIdentityManager = {
********************************************************/
rejectVerification: function(aReason) {
if (!this.activeVerificationDeferred) {
return;
}
this.activeVerificationDeferred.reject(aReason);
this.activeVerificationDeferred = null;
- this.cleanupVerification(true);
+ this.cleanupVerification(true /* unregister */);
},
resolveVerification: function(aResult) {
if (!this.activeVerificationDeferred) {
return;
}
this.activeVerificationDeferred.resolve(aResult);
this.activeVerificationDeferred = null;
this.cleanupVerification();
},
- cleanupVerification: function() {
+ cleanupVerification: function(aUnregister = false) {
if (!this.activeVerificationFlow) {
return;
}
- this.activeVerificationFlow.cleanup();
+ this.activeVerificationFlow.cleanup(aUnregister);
this.activeVerificationFlow = null;
},
doVerification: function() {
this.activeVerificationFlow.doVerification()
.then(
(verificationResult) => {
log.debug("onVerificationResult ");
--- a/services/mobileid/tests/xpcshell/test_mobileid_manager.js
+++ b/services/mobileid/tests/xpcshell/test_mobileid_manager.js
@@ -1454,8 +1454,59 @@ add_test(function() {
principal: PRINCIPAL,
target: mm,
json: {
promiseId: promiseId,
options: {}
}
});
});
+
+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: {}
+ }
+ });
+});
+