Bug 600202 - Saved HTTP Auth password does not show the 'Forget Password' action (tests) [r=vingtetun]
authorWesley Johnston <wjohnston@mozilla.com>
Wed, 06 Oct 2010 15:51:31 -0400
changeset 66789 5081a265184030ed323c118318caf9898bd4b6d9
parent 66788 e1d25aae9857c8219bbac048127edbdb6cbcd80e
child 66790 6ecfebc0fa1f47fc09f098638f11b801977da0b3
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvingtetun
bugs600202
Bug 600202 - Saved HTTP Auth password does not show the 'Forget Password' action (tests) [r=vingtetun]
mobile/chrome/tests/Makefile.in
mobile/chrome/tests/browser_rememberPassword.js
--- a/mobile/chrome/tests/Makefile.in
+++ b/mobile/chrome/tests/Makefile.in
@@ -60,16 +60,17 @@ include $(topsrcdir)/config/rules.mk
   browser_find.js \
   browser_forms.html \
   browser_forms.js \
   browser_mainui.js \
   browser_navigation.js \
   browser_preferences_basic.js \
   browser_preferences_text.js \
   browser_rect.js \
+  browser_rememberPassword.js \
   browser_select.html \
   browser_select.js \
   browser_sessionstore.js \
   browser_tabs.js \
   browser_tapping.js \
   browser_tap_content.html \
   browser_test.js \
   browser_viewport.js \
new file mode 100644
--- /dev/null
+++ b/mobile/chrome/tests/browser_rememberPassword.js
@@ -0,0 +1,59 @@
+var testURL_01 = chromeRoot + "browser_blank_01.html";
+
+// Tests for the Remember Password UI
+
+let gCurrentTab = null;
+function test() {
+  waitForExplicitFinish();
+
+  gCurrentTab = Browser.addTab(testURL_01, true);
+  messageManager.addMessageListener("pageshow", function() {
+    if (gCurrentTab.browser.currentURI.spec == testURL_01) {
+      messageManager.removeMessageListener("pageshow", arguments.callee);
+      pageLoaded();
+    }
+  });
+}
+
+function pageLoaded() {
+  let iHandler = getIdentityHandler();
+  let iPassword = document.getElementById("pageaction-password");
+  let lm = getLoginManager();
+  let host = gCurrentTab.browser.currentURI.prePath;
+  let nullSubmit = createLogin(host, host, null);
+  let nullForm   = createLogin(host, null, "realm");
+
+  lm.removeAllLogins();
+
+  iHandler.show();
+  is(iPassword.hidden, true, "Remember password hidden for no logins");
+  iHandler.hide();
+
+  lm.addLogin(nullSubmit);
+  iHandler.show();
+  is(iPassword.hidden, false, "Remember password shown for form logins");
+  iPassword.click();
+  is(iPassword.hidden, true, "Remember password hidden after click");
+  is(lm.countLogins(host, "", null), 0, "Logins deleted when clicked");
+  iHandler.hide();
+
+  lm.addLogin(nullForm);
+  iHandler.show();
+  is(iPassword.hidden, false, "Remember password shown for protocol logins");
+  iPassword.click();
+  is(iPassword.hidden, true, "Remember password hidden after click");
+  is(lm.countLogins(host, null, ""), 0, "Logins deleted when clicked");
+  iHandler.hide();
+
+  Browser.closeTab(gCurrentTab);
+  finish();
+}
+
+function getLoginManager() {
+  return Components.classes["@mozilla.org/login-manager;1"].getService(Components.interfaces.nsILoginManager);
+}
+
+function createLogin(aHostname, aFormSubmitURL, aRealm) {
+  let nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Components.interfaces.nsILoginInfo, "init");
+  return new nsLoginInfo(aHostname, aFormSubmitURL, aRealm, "username", "password", "uname", "pword");   
+}