Bug 1042769 - Add automated test for checking that the metainfo fields are displayed in password manager. r=paolo
authorMihaela Velimiroviciu <mihaela.velimiroviciu@softvisioninc.eu>
Tue, 29 Jul 2014 17:18:15 +0300
changeset 200203 064789f0d3878c63410aba2776d3f57716ac028c
parent 200202 a5de6212a18cb19d7a26ea363cd8bc9cd78bb88b
child 200204 ad6931ea53e40adb479c4281b6545b5fa19090fc
push id27337
push useremorley@mozilla.com
push dateTue, 19 Aug 2014 12:40:34 +0000
treeherdermozilla-central@a38daccaa557 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs1042769
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1042769 - Add automated test for checking that the metainfo fields are displayed in password manager. r=paolo
toolkit/components/passwordmgr/test/browser/browser.ini
toolkit/components/passwordmgr/test/browser/browser_passwordmgr_fields.js
--- a/toolkit/components/passwordmgr/test/browser/browser.ini
+++ b/toolkit/components/passwordmgr/test/browser/browser.ini
@@ -1,6 +1,7 @@
 [DEFAULT]
 
+[browser_passwordmgr_fields.js]
 [browser_passwordmgr_observers.js]
 [browser_passwordmgr_sort.js]
 [browser_passwordmgrcopypwd.js]
 [browser_passwordmgrdlg.js]
new file mode 100644
--- /dev/null
+++ b/toolkit/components/passwordmgr/test/browser/browser_passwordmgr_fields.js
@@ -0,0 +1,65 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function test() {
+  waitForExplicitFinish();
+
+  let pwmgr = Cc["@mozilla.org/login-manager;1"].
+                getService(Ci.nsILoginManager);
+  pwmgr.removeAllLogins();
+
+  // add login data
+  let nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
+                                                 Ci.nsILoginInfo, "init");
+  let login = new nsLoginInfo("http://example.com/", "http://example.com/", null,
+                              "user", "password", "u1", "p1");
+  pwmgr.addLogin(login);
+
+  // Open the password manager dialog
+  const PWMGR_DLG = "chrome://passwordmgr/content/passwordManager.xul";
+  let pwmgrdlg = window.openDialog(PWMGR_DLG, "Toolkit:PasswordManager", "");
+  SimpleTest.waitForFocus(doTest, pwmgrdlg);
+
+  function doTest() {
+    let doc = pwmgrdlg.document;
+
+    let signonsTree = doc.querySelector("#signonsTree");
+    is(signonsTree.view.rowCount, 1, "One entry in the passwords list");
+
+    is(signonsTree.view.getCellText(0, signonsTree.columns.getNamedColumn("siteCol")),
+       "http://example.com/",
+       "Correct website saved");
+
+    is(signonsTree.view.getCellText(0, signonsTree.columns.getNamedColumn("userCol")),
+       "user",
+       "Correct user saved");
+
+    let timeCreatedCol = doc.getElementById("timeCreatedCol");
+    is(timeCreatedCol.getAttribute("hidden"), "true",
+       "Time created column is not displayed");
+
+
+    let timeLastUsedCol = doc.getElementById("timeLastUsedCol");
+    is(timeLastUsedCol.getAttribute("hidden"), "",
+       "Last Used column is displayed");
+
+    let timePasswordChangedCol = doc.getElementById("timePasswordChangedCol");
+    is(timePasswordChangedCol.getAttribute("hidden"), "",
+       "Last Changed column is displayed");
+
+    // cleanup
+    Services.ww.registerNotification(function (aSubject, aTopic, aData) {
+      if (aSubject.location == pwmgrdlg.location && aTopic == "domwindowclosed") {
+        // unregister ourself
+        Services.ww.unregisterNotification(arguments.callee);
+
+        pwmgr.removeAllLogins();
+
+        finish();
+      }
+    });
+
+    pwmgrdlg.close();
+  }
+}