Bug 1560431 - Enable about:logins on Nightly channel. r=sfoster
authorJared Wein <jwein@mozilla.com>
Thu, 18 Jul 2019 16:24:29 +0000
changeset 483342 a79ff5d4f88ca6252947222fef97d9175f2feec4
parent 483341 b2a000807701617bb5897914d862595855f8b66d
child 483343 db2f5792cd6e3eda65468905c5a91f0e5b2fddc8
push id36313
push useropoprus@mozilla.com
push dateThu, 18 Jul 2019 21:50:51 +0000
treeherdermozilla-central@5fceb8c496bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs1560431
milestone70.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 1560431 - Enable about:logins on Nightly channel. r=sfoster Differential Revision: https://phabricator.services.mozilla.com/D36344
browser/app/profile/firefox.js
browser/components/preferences/in-content/tests/browser_password_management.js
toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js
toolkit/components/passwordmgr/test/browser/browser_context_menu.js
toolkit/components/passwordmgr/test/browser/browser_entry_point_telemetry.js
toolkit/components/passwordmgr/test/browser/browser_openPasswordManager.js
toolkit/components/passwordmgr/test/browser/head.js
toolkit/components/passwordmgr/test/mochitest/test_autocomplete_highlight_non_login.html
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1742,17 +1742,22 @@ pref("extensions.pocket.enabled", true);
 pref("extensions.pocket.oAuthConsumerKey", "40249-e88c401e1b1f2242d9e441c4");
 pref("extensions.pocket.site", "getpocket.com");
 
 pref("signon.generation.available", true);
 pref("signon.generation.enabled", true);
 pref("signon.schemeUpgrades", true);
 pref("signon.privateBrowsingCapture.enabled", true);
 pref("signon.showAutoCompleteFooter", true);
+#ifdef NIGHTLY_BUILD
+pref("signon.management.page.enabled", true);
+pref("signon.management.overrideURI", "about:logins?filter=%DOMAIN%");
+#else
 pref("signon.management.page.enabled", false);
+#endif
 #ifdef NIGHTLY_BUILD
 // Bug 1563330 tracks shipping this by default.
 pref("signon.showAutoCompleteOrigins", true);
 pref("signon.includeOtherSubdomainsInLookup", true);
 #endif
 pref("signon.management.page.faqURL", "https://lockwise.firefox.com/faq.html");
 pref("signon.management.page.feedbackURL",
      "https://www.surveygizmo.com/s3/5036102/Lockwise-feedback?ver=%VERSION%");
--- a/browser/components/preferences/in-content/tests/browser_password_management.js
+++ b/browser/components/preferences/in-content/tests/browser_password_management.js
@@ -4,16 +4,17 @@ ChromeUtils.import("resource://testing-c
 
 const PM_URL = "chrome://passwordmgr/content/passwordManager.xul";
 const PREF_MANAGEMENT_URI = "signon.management.overrideURI";
 
 var passwordsDialog;
 
 add_task(async function test_setup() {
   Services.logins.removeAllLogins();
+  Services.prefs.setCharPref(PREF_MANAGEMENT_URI, "");
 
   // add login data
   let nsLoginInfo = new Components.Constructor(
     "@mozilla.org/login-manager/loginInfo;1",
     Ci.nsILoginInfo,
     "init"
   );
   let login = new nsLoginInfo(
--- a/toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js
@@ -67,31 +67,34 @@ add_task(async function test_autocomplet
 
       let footer = popup.querySelector(`[originaltype="loginsFooter"]`);
       ok(footer, "Got footer richlistitem");
 
       await TestUtils.waitForCondition(() => {
         return !EventUtils.isHidden(footer);
       }, "Waiting for footer to become visible");
 
-      EventUtils.synthesizeMouseAtCenter(footer, {});
-      let window = await waitForPasswordManagerDialog();
-      info("Login dialog was opened");
+      let openingFunc = () => EventUtils.synthesizeMouseAtCenter(footer, {});
+      let passwordManager = await openPasswordManager(openingFunc, true);
+
+      info("Password Manager was opened");
 
-      await TestUtils.waitForCondition(() => {
-        return window.document.getElementById("filter").value == "example.com";
-      }, "Waiting for the search string to filter logins");
+      is(
+        passwordManager.filterValue,
+        "example.com",
+        "Search string should be set to filter logins"
+      );
 
       // Check event telemetry recorded when opening management UI
       TelemetryTestUtils.assertEvents(
         [["pwmgr", "open_management", "autocomplete"]],
         { category: "pwmgr", method: "open_management" }
       );
 
-      window.close();
+      await passwordManager.close();
       popup.hidePopup();
     }
   );
 });
 
 add_task(async function test_autocomplete_footer_keydown() {
   let url = TEST_ORIGIN + BASIC_FORM_PAGE_PATH;
   await BrowserTestUtils.withNewTab(
@@ -110,28 +113,30 @@ add_task(async function test_autocomplet
 
       await TestUtils.waitForCondition(() => {
         return !EventUtils.isHidden(footer);
       }, "Waiting for footer to become visible");
 
       await EventUtils.synthesizeKey("KEY_ArrowDown");
       await EventUtils.synthesizeKey("KEY_ArrowDown");
       await EventUtils.synthesizeKey("KEY_ArrowDown");
-      await EventUtils.synthesizeKey("KEY_Enter");
+      let openingFunc = () => EventUtils.synthesizeKey("KEY_Enter");
 
-      let window = await waitForPasswordManagerDialog();
+      let passwordManager = await openPasswordManager(openingFunc, true);
       info("Login dialog was opened");
 
-      await TestUtils.waitForCondition(() => {
-        return window.document.getElementById("filter").value == "example.com";
-      }, "Waiting for the search string to filter logins");
+      is(
+        passwordManager.filterValue,
+        "example.com",
+        "Search string should be set to filter logins"
+      );
 
       // Check event telemetry recorded when opening management UI
       TelemetryTestUtils.assertEvents(
         [["pwmgr", "open_management", "autocomplete"]],
         { category: "pwmgr", method: "open_management" }
       );
 
-      window.close();
+      await passwordManager.close();
       popup.hidePopup();
     }
   );
 });
--- a/toolkit/components/passwordmgr/test/browser/browser_context_menu.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_context_menu.js
@@ -379,27 +379,27 @@ add_task(async function test_context_men
   await BrowserTestUtils.withNewTab(
     {
       gBrowser,
       url: TEST_ORIGIN + MULTIPLE_FORMS_PAGE_PATH,
     },
     async function(browser) {
       await openPasswordContextMenu(browser, "#test-password-1");
 
-      gContextMenu.openPasswordManager();
+      let openingFunc = () => gContextMenu.openPasswordManager();
       // wait until the management UI opens
-      let dialogWindow = await waitForPasswordManagerDialog();
+      let passwordManager = await openPasswordManager(openingFunc);
       info("Management UI dialog was opened");
 
       TelemetryTestUtils.assertEvents(
         [["pwmgr", "open_management", "contextmenu"]],
         { category: "pwmgr", method: "open_management" }
       );
 
-      dialogWindow.close();
+      await passwordManager.close();
       CONTEXT_MENU.hidePopup();
     }
   );
 });
 
 /**
  * Verify that only the expected form fields are filled.
  */
--- a/toolkit/components/passwordmgr/test/browser/browser_entry_point_telemetry.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_entry_point_telemetry.js
@@ -34,27 +34,27 @@ add_task(async function mainMenu_entryPo
 
   let item = document.getElementById("appMenu-logins-button");
   await TestUtils.waitForCondition(
     () => BrowserTestUtils.is_visible(item),
     "Logins and passwords button is visible."
   );
 
   info("mainMenu_entryPoint, clicking on Logins and passwords button");
-  EventUtils.synthesizeMouseAtCenter(item, {});
-  let dialogWindow = await waitForPasswordManagerDialog();
+  let openingFunc = () => EventUtils.synthesizeMouseAtCenter(item, {});
+  let passwordManager = await openPasswordManager(openingFunc);
   info("mainMenu_entryPoint, password manager dialog shown");
 
   TelemetryTestUtils.assertEvents([["pwmgr", "open_management", "mainmenu"]], {
     category: "pwmgr",
     method: "open_management",
   });
 
   info("mainMenu_entryPoint, close dialog and main menu");
-  dialogWindow.close();
+  await passwordManager.close();
   mainMenu.hidePopup();
 });
 
 add_task(async function pageInfo_entryPoint() {
   await BrowserTestUtils.withNewTab(
     {
       gBrowser,
       url: TEST_ORIGIN,
@@ -71,24 +71,25 @@ add_task(async function pageInfo_entryPo
       );
 
       await TestUtils.waitForCondition(
         () => BrowserTestUtils.is_visible(passwordsButton),
         "Show passwords button should be visible."
       );
       info("pageInfo_entryPoint, clicking the show passwords button...");
       await SimpleTest.promiseFocus(pageInfo);
-      await EventUtils.synthesizeMouseAtCenter(passwordsButton, {}, pageInfo);
+      let openingFunc = () =>
+        EventUtils.synthesizeMouseAtCenter(passwordsButton, {}, pageInfo);
 
       info("pageInfo_entryPoint, waiting for the passwords manager dialog");
-      let dialogWindow = await waitForPasswordManagerDialog();
+      let passwordManager = await openPasswordManager(openingFunc);
 
       TelemetryTestUtils.assertEvents(
         [["pwmgr", "open_management", "pageinfo"]],
         { category: "pwmgr", method: "open_management" }
       );
 
       info("pageInfo_entryPoint, close dialog and pageInfo");
-      dialogWindow.close();
+      await passwordManager.close();
       pageInfo.close();
     }
   );
 });
--- a/toolkit/components/passwordmgr/test/browser/browser_openPasswordManager.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_openPasswordManager.js
@@ -2,38 +2,42 @@ const PREF_MANAGEMENT_URI = "signon.mana
 
 function resetPrefs() {
   Services.prefs.clearUserPref(PREF_MANAGEMENT_URI);
 }
 
 registerCleanupFunction(resetPrefs);
 
 add_task(async function test_noFilter() {
-  LoginHelper.openPasswordManager(window, { entryPoint: "mainmenu" });
-  let win = await waitForPasswordManagerDialog();
-  ok(win, "Login dialog was opened");
-  await BrowserTestUtils.closeWindow(win);
+  let openingFunc = () =>
+    LoginHelper.openPasswordManager(window, { entryPoint: "mainmenu" });
+  let passwordManager = await openPasswordManager(openingFunc);
+
+  ok(passwordManager, "Login dialog was opened");
+  await passwordManager.close();
   await TestUtils.waitForCondition(() => {
     return Services.wm.getMostRecentWindow("Toolkit:PasswordManager") === null;
   }, "Waiting for the password manager dialog to close");
 });
 
 add_task(async function test_filter() {
   // Greek IDN for example.test
   let domain = "παράδειγμα.δοκιμή";
-  LoginHelper.openPasswordManager(window, {
-    filterString: domain,
-    entryPoint: "mainmenu",
-  });
-  let win = await waitForPasswordManagerDialog();
-  await TestUtils.waitForCondition(() => {
-    return win.document.getElementById("filter").value == domain;
-  }, "Waiting for the search string to filter logins");
-  ok(win, "Login dialog was opened with a domain filter");
-  await BrowserTestUtils.closeWindow(win);
+  let openingFunc = () =>
+    LoginHelper.openPasswordManager(window, {
+      filterString: domain,
+      entryPoint: "mainmenu",
+    });
+  let passwordManager = await openPasswordManager(openingFunc, true);
+  is(
+    passwordManager.filterValue,
+    domain,
+    "search string to filter logins should match expectation"
+  );
+  await passwordManager.close();
   await TestUtils.waitForCondition(() => {
     return Services.wm.getMostRecentWindow("Toolkit:PasswordManager") === null;
   }, "Waiting for the password manager dialog to close");
 });
 
 add_task(async function test_management_overrideURI_noFilter() {
   await SpecialPowers.pushPrefEnv({
     set: [["signon.management.page.enabled", true]],
--- a/toolkit/components/passwordmgr/test/browser/head.js
+++ b/toolkit/components/passwordmgr/test/browser/head.js
@@ -201,24 +201,63 @@ async function checkDoorhangerUsernamePa
     document.getElementById("password-notification-password").value,
     password,
     "Check doorhanger password"
   );
 }
 
 // End popup notification (doorhanger) functions //
 
-async function waitForPasswordManagerDialog() {
+async function waitForPasswordManagerDialog(openingFunc) {
   let win;
+  await openingFunc();
   await TestUtils.waitForCondition(() => {
     win = Services.wm.getMostRecentWindow("Toolkit:PasswordManager");
     return win && win.document.getElementById("filter");
   }, "Waiting for the password manager dialog to open");
 
-  return win;
+  return {
+    filterValue: win.document.getElementById("filter").value,
+    async close() {
+      await BrowserTestUtils.closeWindow(win);
+    },
+  };
+}
+
+async function waitForPasswordManagerTab(openingFunc, waitForFilter) {
+  info("waiting for new tab to open");
+  let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, null);
+  await openingFunc();
+  let tab = await tabPromise;
+  ok(tab, "got password management tab");
+  let filterValue;
+  if (waitForFilter) {
+    filterValue = await ContentTask.spawn(tab.linkedBrowser, null, async () => {
+      let loginFilter = Cu.waiveXrays(
+        content.document.querySelector("login-filter")
+      );
+      await ContentTaskUtils.waitForCondition(
+        () => !!loginFilter.value,
+        "wait for login-filter to have a value"
+      );
+      return loginFilter.value;
+    });
+  }
+  return {
+    filterValue,
+    close() {
+      BrowserTestUtils.removeTab(tab);
+    },
+  };
+}
+
+function openPasswordManager(openingFunc, waitForFilter) {
+  return Services.prefs.getCharPref("signon.management.overrideURI")
+    ? waitForPasswordManagerTab(openingFunc, waitForFilter)
+    : waitForPasswordManagerDialog(openingFunc);
 }
 
 // Contextmenu functions //
 
 /**
  * Synthesize mouse clicks to open the password manager context menu popup
  * for a target password input element.
  *
--- a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_highlight_non_login.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_highlight_non_login.html
@@ -93,18 +93,23 @@ add_task(async function test_field_highl
   await new Promise(resolve => setTimeout(resolve, 1000));
   is(document.defaultView.getComputedStyle(password).getPropertyValue("filter"), "none",
      "Highlight is not applied to the password field if enter key is pressed on the footer item");
   is(document.defaultView.getComputedStyle(username).getPropertyValue("filter"), "none",
      "Highlight is not applied to the username field if enter key is pressed on the footer item");
 
   runInParent(function cleanUpWindow() {
     const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-    let window = Services.wm.getMostRecentWindow("Toolkit:PasswordManager");
-    window.close();
+    if (Services.prefs.getCharPref("signon.management.overrideURI")) {
+      let window = Services.wm.getMostRecentWindow("navigator:browser");
+      window.gBrowser.removeTab(window.gBrowser.selectedTab);
+    } else {
+      let window = Services.wm.getMostRecentWindow("Toolkit:PasswordManager");
+      window.close();
+    }
   });
 
   // Press tab on the footer and check.
   password.focus();
   shownPromise = promiseACShown();
   synthesizeKey("KEY_ArrowDown"); // open popup
   await shownPromise;
   synthesizeKey("KEY_ArrowUp"); // footer