Bug 1529729 - Honour signon.management.overrideURI for the Saved Logins prefs UI. r=jaws
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Thu, 14 Mar 2019 04:53:57 +0000
changeset 521829 e4a6f915841a
parent 521828 30dfd6603f79
child 521830 bc61185b6f57
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1529729
milestone67.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 1529729 - Honour signon.management.overrideURI for the Saved Logins prefs UI. r=jaws If `signon.management.overrideURI` is set, open that URI in a new tab instead of opening the preferences subdialog. Differential Revision: https://phabricator.services.mozilla.com/D23206
browser/components/preferences/in-content/privacy.js
browser/components/preferences/in-content/tests/browser_password_management.js
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -1299,16 +1299,20 @@ var gPrivacyPane = {
       "resizable=no", null, this._initMasterPasswordUI.bind(this));
   },
 
   /**
  * Shows the sites where the user has saved passwords and the associated login
  * information.
  */
   showPasswords() {
+    if (LoginHelper.managementURI) {
+      window.docShell.messageManager.sendAsyncMessage("PasswordManager:OpenPreferences", {});
+      return;
+    }
     gSubDialog.open("chrome://passwordmgr/content/passwordManager.xul");
   },
 
   /**
    * Enables/disables the Exceptions button used to configure sites where
    * passwords are never saved. When browser is set to start in Private
    * Browsing mode, the "Remember passwords" UI is useless, so we disable it.
    */
--- a/browser/components/preferences/in-content/tests/browser_password_management.js
+++ b/browser/components/preferences/in-content/tests/browser_password_management.js
@@ -1,42 +1,31 @@
 "use strict";
 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();
 
   // 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");
   Services.logins.addLogin(login);
 
   registerCleanupFunction(async function() {
     Services.logins.removeAllLogins();
+    Services.prefs.clearUserPref(PREF_MANAGEMENT_URI);
   });
 });
 
 add_task(async function test_openPasswordSubDialog() {
-  // Undo the save password change.
-  registerCleanupFunction(async function() {
-    await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
-      let doc = content.document;
-      let savePasswordCheckBox = doc.getElementById("savePasswords");
-      if (savePasswordCheckBox.checked) {
-        savePasswordCheckBox.click();
-      }
-    });
-
-    gBrowser.removeCurrentTab();
-  });
-
   await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
 
   let dialogOpened = promiseLoadSubDialog(PM_URL);
 
   await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
     let doc = content.document;
     let savePasswordCheckBox = doc.getElementById("savePasswords");
     Assert.ok(!savePasswordCheckBox.checked,
@@ -64,8 +53,39 @@ add_task(async function test_deletePassw
     EventUtils.synthesizeKey("KEY_Delete");
   }
 
   await TestUtils.waitForCondition(() => tree.view.rowCount == 0);
 
   is_element_visible(content.gSubDialog._dialogs[0]._box,
     "Subdialog is visible after deleting an element");
 });
+
+add_task(async function subdialog_cleanup() {
+  // Undo the save password change.
+  await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
+    let doc = content.document;
+    let savePasswordCheckBox = doc.getElementById("savePasswords");
+    if (savePasswordCheckBox.checked) {
+      savePasswordCheckBox.click();
+    }
+  });
+  gBrowser.removeCurrentTab();
+});
+
+add_task(async function test_openPasswordManagement_overrideURI() {
+  Services.prefs.setStringPref(PREF_MANAGEMENT_URI, "about:logins?filter=%DOMAIN%");
+  await openPreferencesViaOpenPreferencesAPI("privacy", {leaveOpen: true});
+
+  let tabOpenPromise = BrowserTestUtils.waitForNewTab(gBrowser, "about:logins?filter=");
+
+  await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
+    let doc = content.document;
+    let showPasswordsButton = doc.getElementById("showPasswords");
+    showPasswordsButton.click();
+  });
+
+  let tab = await tabOpenPromise;
+  ok(tab, "Tab opened");
+  BrowserTestUtils.removeTab(tab);
+  Services.prefs.clearUserPref(PREF_MANAGEMENT_URI);
+  gBrowser.removeCurrentTab();
+});