зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
76e998252a
Коммит
7904dca00a
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче