Bug 649739: send userabort reason for J-PAKE cancelation. r=philiKON

This commit is contained in:
Richard Newman 2011-04-14 10:49:54 -07:00
parent 000314e7f9
commit fe7f22191a
3 changed files with 19 additions and 9 deletions

View File

@ -185,6 +185,7 @@ JPAKE_ERROR_INVALID: "jpake.error.invalid",
JPAKE_ERROR_NODATA: "jpake.error.nodata",
JPAKE_ERROR_KEYMISMATCH: "jpake.error.keymismatch",
JPAKE_ERROR_WRONGMESSAGE: "jpake.error.wrongmessage",
JPAKE_ERROR_USERABORT: "jpake.error.userabort",
// Ways that a sync can be disabled (messages only to be printed in debug log)
kSyncMasterPasswordLocked: "User elected to leave Master Password locked",

View File

@ -203,6 +203,11 @@ JPAKEClient.prototype = {
this._log.debug("Aborting...");
this._finished = true;
let self = this;
// Default to "user aborted".
if (!error)
error = JPAKE_ERROR_USERABORT;
if (error == JPAKE_ERROR_CHANNEL
|| error == JPAKE_ERROR_NETWORK
|| error == JPAKE_ERROR_NODATA) {

View File

@ -262,16 +262,18 @@ function test_abort_receiver(next) {
do_throw("onComplete shouldn't be called.");
},
onAbort: function onAbort(error) {
// Manual abort = no error
do_check_eq(error, undefined);
// Ensure channel was cleared, no error report.
// Manual abort = userabort.
do_check_eq(error, JPAKE_ERROR_USERABORT);
// Ensure channel was cleared.
do_check_eq(channels[this.cid].data, undefined);
do_check_eq(error_report, undefined);
do_check_eq(error_report, JPAKE_ERROR_USERABORT);
error_report = undefined;
next();
},
displayPIN: function displayPIN(pin) {
this.cid = pin.slice(JPAKE_LENGTH_SECRET);
Utils.delay(function() { rec.abort(); }, 0, this, "_timer");
Utils.delay(function() { rec.abort(); },
0, this, "_timer");
}
});
rec.receiveNoPIN();
@ -286,8 +288,10 @@ function test_abort_sender(next) {
do_throw("displayPIN shouldn't have been called!");
},
onAbort: function onAbort(error) {
// Manual abort == no error.
do_check_eq(error, undefined);
// Manual abort == userabort.
do_check_eq(error, JPAKE_ERROR_USERABORT);
do_check_eq(error_report, JPAKE_ERROR_USERABORT);
error_report = undefined;
},
onComplete: function onComplete() {
do_throw("Shouldn't have completed!");
@ -310,8 +314,8 @@ function test_abort_sender(next) {
this.cid = pin.slice(JPAKE_LENGTH_SECRET);
Utils.delay(function() { snd.sendWithPIN(pin, DATA); }, 0,
this, "_timer");
Utils.delay(function() { snd.abort(); }, POLLINTERVAL,
this, "_abortTimer");
Utils.delay(function() { snd.abort(); },
POLLINTERVAL, this, "_abortTimer");
}
});
rec.receiveNoPIN();