Bug 585740 - Weave.Service.login() should start trackers if it's called in lieu of a setup process [r=mconnor]

This commit is contained in:
Philipp von Weitershausen 2010-08-10 01:46:54 +02:00
Родитель 76e998252a
Коммит 7904dca00a
2 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -766,6 +766,7 @@ WeaveSvc.prototype = {
if (Svc.IO.offline)
throw "Application is offline, login should not be called";
let initialStatus = this._checkSetup();
if (username)
this.username = username;
if (password)
@ -776,6 +777,12 @@ WeaveSvc.prototype = {
if (this._checkSetup() == CLIENT_NOT_CONFIGURED)
throw "aborting login, client not configured";
// Calling login() with parameters when the client was
// previously not configured means setup was completed.
if (initialStatus == CLIENT_NOT_CONFIGURED
&& (username || password || passphrase))
Svc.Obs.notify("weave:service:setup-complete");
this._log.info("Logging in user " + this.username);
if (!this.verifyLogin()) {

Просмотреть файл

@ -78,6 +78,21 @@ function run_test() {
do_check_eq(Status.login, LOGIN_SUCCEEDED);
do_check_true(Weave.Service.isLoggedIn);
do_check_true(Svc.Prefs.get("autoconnect"));
_("Calling login() with parameters when the client is unconfigured sends notification.");
let notified = false;
Weave.Svc.Obs.add("weave:service:setup-complete", function() {
notified = true;
});
Weave.Service.username = "";
Weave.Service.password = "";
Weave.Service.passphrase = "";
Weave.Service.login("janedoe", "ilovejohn", "bar");
do_check_true(notified);
do_check_eq(Status.service, STATUS_OK);
do_check_eq(Status.login, LOGIN_SUCCEEDED);
do_check_true(Weave.Service.isLoggedIn);
do_check_true(Svc.Prefs.get("autoconnect"));
_("Logout.");
Weave.Service.logout();