From 930ebc17e6b6bbdf5cda4d16b5bdfe5b1ac0c384 Mon Sep 17 00:00:00 2001 From: "ctalbert@mozilla.com" Date: Fri, 16 May 2008 09:59:37 -0700 Subject: [PATCH] bug 433936 r=jay Fix QAC login process --- .../community/chrome/content/prefs.js | 4 +- .../extensions/community/chrome/content/qa.js | 44 +++++++++++++++++++ .../chrome/locale/en-US/qa.properties | 5 ++- testing/extensions/community/install.rdf | 4 +- 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/testing/extensions/community/chrome/content/prefs.js b/testing/extensions/community/chrome/content/prefs.js index bf63c193176..50ee2784d70 100755 --- a/testing/extensions/community/chrome/content/prefs.js +++ b/testing/extensions/community/chrome/content/prefs.js @@ -176,7 +176,7 @@ var CC_loginManager = Components.classes["@mozilla.org/login-manager;1"]; // The LoginManager does not like "null" for username/password fields, // So we send in the field names from the XUL. - var newLogin = new nsLoginInfo('chrome://qa', 'Litmus Login', litmus.baseURL, + var newLogin = new nsLoginInfo('chrome://qa', null, litmus.baseURL, username, password, "username", "password"); try { this.manager().addLogin(newLogin); @@ -187,7 +187,7 @@ var CC_loginManager = Components.classes["@mozilla.org/login-manager;1"]; getPasswordObj: function() { try { var logins = this.manager().findLogins({}, 'chrome://qa', - 'Litmus Login', litmus.baseURL); + null, litmus.baseURL); if (logins.length > 0 && logins[0] != null) return logins[0]; return false; diff --git a/testing/extensions/community/chrome/content/qa.js b/testing/extensions/community/chrome/content/qa.js index b7cf07b3d76..2c47e1911d1 100755 --- a/testing/extensions/community/chrome/content/qa.js +++ b/testing/extensions/community/chrome/content/qa.js @@ -47,6 +47,11 @@ var qaMain = { window.open("chrome://qa/content/setup.xul", "_blank", "chrome,all,dialog=yes"); } + else { + // We need to log the user into litmus + var storedLogin = qaPref.litmus.getPasswordObj(); + this.correctCredentials(storedLogin.username, storedLogin.password, false); + } if (qaPref.getPref(qaPref.prefBase + '.currentTestcase.testrunSummary', 'char') != null) { litmus.readStateFromPref(); } @@ -68,6 +73,45 @@ var qaMain = { } qaPrefsWindow.lastSelectedTab = newSelection; + }, + + correctCredentials : function(username, password,isSecondTry) { + var callback = function (resp) { + if (resp.responseText == 0) { + qaMain.doLogin(isSecondTry); + } else { + // Then we need to store our validated creds + qaPref.litmus.setPassword(username, password); + } + } + + // First we validate our stored login. + litmus.validateLogin(username, password, callback); + }, + + doLogin : function(isSecondTry) { + try { + var username = {value: "username"}; + var password = {value: "password"}; + var check = {value: "null"}; + var title = qaMain.bundle.getString("qa.getpassword.title"); + var msg = ""; + + if (!isSecondTry) + msg = qaMain.bundle.getString("qa.getpassword.message"); + else + msg = qaMain.bundle.getString("qa.getpassword.tryagainmessage"); + + var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + var result = prompts.promptUsernameAndPassword(null, title, msg, username, + password, null, check); + + this.correctCredentials(username.value, password.value, true); + } catch(ex) { + alert("ERROR LOGGING IN: " + ex); + dump("Error logging in: " + ex); + } } }; diff --git a/testing/extensions/community/chrome/locale/en-US/qa.properties b/testing/extensions/community/chrome/locale/en-US/qa.properties index 1b1debafb53..40f2a185d22 100755 --- a/testing/extensions/community/chrome/locale/en-US/qa.properties +++ b/testing/extensions/community/chrome/locale/en-US/qa.properties @@ -42,4 +42,7 @@ qa.extension.prefs.savedMsg = Your settings have been saved qa.extension.sysconfig.loadingMsg = Loading menu options... qa.extension.loading = Loading... qa.extension.litmus.progress = Now Testing %1$S of %2$S -qa.extension.litmus.stats = Tests Completed - Week: %1$S, Month: %2$S, All Time: %3$S \ No newline at end of file +qa.extension.litmus.stats = Tests Completed - Week: %1$S, Month: %2$S, All Time: %3$S +qa.getpassword.title = Login to Litmus +qa.getpassword.message = Enter the login information for your Litmus Account +qa.getpassword.tryagainmessage = Incorrect login information. Please enter the email address and password for your Litmus Account, if you have forgotten it, ask on IRC in #qa to have it reset. diff --git a/testing/extensions/community/install.rdf b/testing/extensions/community/install.rdf index 1f48f230763..143664db92a 100644 --- a/testing/extensions/community/install.rdf +++ b/testing/extensions/community/install.rdf @@ -5,10 +5,10 @@ + em:maxVersion="3.0.*"/>