Bug 1548463 - Tests for HTML-based login manager. r=MattN
authorJared Wein <jwein@mozilla.com>
Wed, 08 May 2019 18:02:26 +0000
changeset 534993 6632c97e250f79cc93b4a7223b1a3ae87f2b2676
parent 534992 2f50e7dfbc564477f53313400d953cf2381e1cdd
child 534994 0313ad8713b5d1ad045af938ae11bef5f7f5f7ca
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1548463
milestone68.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 1548463 - Tests for HTML-based login manager. r=MattN Differential Revision: https://phabricator.services.mozilla.com/D29625
browser/components/aboutlogins/content/components/login-item.js
browser/components/aboutlogins/content/components/login-list.js
browser/components/aboutlogins/moz.build
browser/components/aboutlogins/tests/browser/browser.ini
browser/components/aboutlogins/tests/browser/browser_deleteLogin.js
browser/components/aboutlogins/tests/browser/browser_loginChanges.js
browser/components/aboutlogins/tests/mochitest/aboutlogins_common.js
browser/components/aboutlogins/tests/mochitest/mochitest.ini
browser/components/aboutlogins/tests/mochitest/test_login_item.html
browser/components/aboutlogins/tests/mochitest/test_login_list.html
browser/components/contextualidentity/test/browser/browser_aboutURLs.js
browser/components/originattributes/test/browser/browser_firstPartyIsolation_aboutPages.js
browser/components/preferences/in-content/tests/browser_password_management.js
toolkit/components/passwordmgr/test/browser/browser_openPasswordManager.js
--- a/browser/components/aboutlogins/content/components/login-item.js
+++ b/browser/components/aboutlogins/content/components/login-item.js
@@ -67,32 +67,36 @@ class LoginItem extends HTMLElement {
     this.shadowRoot.querySelector("input[name='username']").value = this._login.username || "";
     this.shadowRoot.querySelector("input[name='password']").value = this._login.password || "";
     this.shadowRoot.querySelector(".time-created").textContent = this._login.timeCreated || "";
   }
 
   handleEvent(event) {
     switch (event.type) {
       case "AboutLoginsLoginSelected": {
-        this._login = event.detail;
-        this.render();
+        this.setLogin(event.detail);
         break;
       }
       case "click": {
         if (event.target.classList.contains("delete-button")) {
           document.dispatchEvent(new CustomEvent("AboutLoginsDeleteLogin", {
             bubbles: true,
             detail: this._login,
           }));
         }
         break;
       }
     }
   }
 
+  setLogin(login) {
+    this._login = login;
+    this.render();
+  }
+
   loginAdded(login) {
     if (!this._login.guid) {
       let tempLogin = {
         username: this.shadowRoot.querySelector("input[name='username']").value,
         formSubmitURL: "", // Use the wildcard since the user doesn't supply it.
         hostname: this.shadowRoot.querySelector("input[name='hostname']").value,
         password: this.shadowRoot.querySelector("input[name='password']").value,
       };
--- a/browser/components/aboutlogins/content/components/login-list.js
+++ b/browser/components/aboutlogins/content/components/login-list.js
@@ -54,16 +54,22 @@ class LoginList extends HTMLElement {
 
   loginAdded(login) {
     this._logins.push(login);
     let pre = this.shadowRoot.querySelector("pre");
     pre.append(new LoginListItem(login));
   }
 
   loginModified(login) {
+    for (let i = 0; i < this._logins.length; i++) {
+      if (this._logins[i].guid == login.guid) {
+        this._logins[i] = login;
+        break;
+      }
+    }
     let pre = this.shadowRoot.querySelector("pre");
     for (let loginListItem of pre.children) {
       if (loginListItem.getAttribute("guid") == login.guid) {
         loginListItem.update(login);
         break;
       }
     }
   }
--- a/browser/components/aboutlogins/moz.build
+++ b/browser/components/aboutlogins/moz.build
@@ -11,8 +11,11 @@ with Files('**'):
 
 EXTRA_JS_MODULES += [
     'AboutLoginsParent.jsm',
 ]
 
 FINAL_TARGET_FILES.actors += [
     'AboutLoginsChild.jsm',
 ]
+
+BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
+MOCHITEST_MANIFESTS += ['tests/mochitest/mochitest.ini']
new file mode 100644
--- /dev/null
+++ b/browser/components/aboutlogins/tests/browser/browser.ini
@@ -0,0 +1,6 @@
+[DEFAULT]
+prefs =
+  signon.management.page.enabled=true
+
+[browser_deleteLogin.js]
+[browser_loginChanges.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/aboutlogins/tests/browser/browser_deleteLogin.js
@@ -0,0 +1,62 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+let gLogins = [{
+    guid: "70a",
+    username: "jared",
+    password: "deraj",
+    hostname: "https://www.example.com",
+  }, {
+    guid: "70b",
+    username: "firefox",
+    password: "xoferif",
+    hostname: "https://www.example.com",
+  },
+];
+
+add_task(async function setup() {
+  await BrowserTestUtils.openNewForegroundTab({gBrowser, url: "about:logins"});
+  registerCleanupFunction(() => {
+    BrowserTestUtils.removeTab(gBrowser.selectedTab);
+  });
+});
+
+add_task(async function test_show_logins() {
+  let browser = gBrowser.selectedBrowser;
+  browser.messageManager.sendAsyncMessage("AboutLogins:AllLogins", gLogins);
+
+  await ContentTask.spawn(browser, gLogins, async (logins) => {
+    let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
+    let loginFound = await ContentTaskUtils.waitForCondition(() => {
+      return loginList._logins.length == 2 &&
+             loginList._logins[0].guid == logins[0].guid &&
+             loginList._logins[1].guid == logins[1].guid;
+    }, "Waiting for logins to be displayed");
+    ok(loginFound, "Newly added logins should be added to the page");
+  });
+});
+
+add_task(async function test_login_item() {
+  let browser = gBrowser.selectedBrowser;
+  let deleteLoginMessageReceived = false;
+  browser.messageManager.addMessageListener("AboutLogins:DeleteLogin", function onMsg() {
+    deleteLoginMessageReceived = true;
+    browser.messageManager.removeMessageListener("AboutLogins:DeleteLogin", onMsg);
+  });
+  await ContentTask.spawn(browser, gLogins, async (logins) => {
+    let loginList = content.document.querySelector("login-list");
+    let loginListItems = loginList.shadowRoot.querySelectorAll("login-list-item");
+    loginListItems[0].click();
+
+    let loginItem = Cu.waiveXrays(content.document.querySelector("login-item"));
+    let loginItemPopulated = await ContentTaskUtils.waitForCondition(() => {
+      return loginItem._login.guid == loginListItems[0].getAttribute("guid");
+    }, "Waiting for login item to get populated");
+    ok(loginItemPopulated, "The login item should get populated");
+
+    let deleteButton = loginItem.shadowRoot.querySelector(".delete-button");
+    deleteButton.click();
+  });
+  ok(deleteLoginMessageReceived,
+     "Clicking the delete button should send the AboutLogins:DeleteLogin messsage");
+});
new file mode 100644
--- /dev/null
+++ b/browser/components/aboutlogins/tests/browser/browser_loginChanges.js
@@ -0,0 +1,69 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+add_task(async function setup() {
+  await BrowserTestUtils.openNewForegroundTab({gBrowser, url: "about:logins"});
+  registerCleanupFunction(() => {
+    BrowserTestUtils.removeTab(gBrowser.selectedTab);
+  });
+});
+
+add_task(async function test_login_added() {
+  let login = {
+    guid: "70",
+    username: "jared",
+    password: "deraj",
+    hostname: "https://www.example.com",
+  };
+  let browser = gBrowser.selectedBrowser;
+  browser.messageManager.sendAsyncMessage("AboutLogins:LoginAdded", login);
+
+  await ContentTask.spawn(browser, login, async (addedLogin) => {
+    let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
+    let loginFound = await ContentTaskUtils.waitForCondition(() => {
+      return loginList._logins.length == 1 &&
+             loginList._logins[0].guid == addedLogin.guid;
+    }, "Waiting for login to be added");
+    ok(loginFound, "Newly added logins should be added to the page");
+  });
+});
+
+add_task(async function test_login_modified() {
+  let login = {
+    guid: "70",
+    username: "jared@example.com",
+    password: "deraj",
+    hostname: "https://www.example.com",
+  };
+  let browser = gBrowser.selectedBrowser;
+  browser.messageManager.sendAsyncMessage("AboutLogins:LoginModified", login);
+
+  await ContentTask.spawn(browser, login, async (modifiedLogin) => {
+    let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
+    let loginFound = await ContentTaskUtils.waitForCondition(() => {
+      return loginList._logins.length == 1 &&
+             loginList._logins[0].guid == modifiedLogin.guid &&
+             loginList._logins[0].username == modifiedLogin.username;
+    }, "Waiting for username to get updated");
+    ok(loginFound, "The login should get updated on the page");
+  });
+});
+
+add_task(async function test_login_removed() {
+  let login = {
+    guid: "70",
+    username: "jared@example.com",
+    password: "deraj",
+    hostname: "https://www.example.com",
+  };
+  let browser = gBrowser.selectedBrowser;
+  browser.messageManager.sendAsyncMessage("AboutLogins:LoginRemoved", login);
+
+  await ContentTask.spawn(browser, login, async (removedLogin) => {
+    let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
+    let loginRemoved = await ContentTaskUtils.waitForCondition(() => {
+      return loginList._logins.length == 0;
+    }, "Waiting for login to get removed");
+    ok(loginRemoved, "The login should be removed from the page");
+  });
+});
new file mode 100644
--- /dev/null
+++ b/browser/components/aboutlogins/tests/mochitest/aboutlogins_common.js
@@ -0,0 +1,26 @@
+"use strict";
+
+/* exported asyncElementRendered, importDependencies */
+
+/**
+ * A helper to await on while waiting for an asynchronous rendering of a Custom
+ * Element.
+ * @returns {Promise}
+ */
+function asyncElementRendered() {
+  return Promise.resolve();
+}
+
+/**
+ * Import the templates from the real page to avoid duplication in the tests.
+ * @param {HTMLIFrameElement} templateFrame - Frame to copy the resources from
+ * @param {HTMLElement} destinationEl - Where to append the copied resources
+ */
+function importDependencies(templateFrame, destinationEl) {
+  let templates = templateFrame.contentDocument.querySelectorAll("template");
+  isnot(templates, null, "Check some templates found");
+  for (let template of templates) {
+    let imported = document.importNode(template, true);
+    destinationEl.appendChild(imported);
+  }
+}
new file mode 100644
--- /dev/null
+++ b/browser/components/aboutlogins/tests/mochitest/mochitest.ini
@@ -0,0 +1,10 @@
+[DEFAULT]
+support-files =
+   ../../content/aboutLogins.html
+   ../../content/components/login-item.js
+   ../../content/components/login-list.js
+   ../../content/components/login-list-item.js
+   aboutlogins_common.js
+
+[test_login_item.html]
+[test_login_list.html]
new file mode 100644
--- /dev/null
+++ b/browser/components/aboutlogins/tests/mochitest/test_login_item.html
@@ -0,0 +1,109 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Test the login-item component
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test the login-item component</title>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script src="login-item.js"></script>
+  <script src="aboutlogins_common.js"></script>
+
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+  <p id="display">
+  </p>
+<div id="content" style="display: none">
+  <iframe id="templateFrame" src="aboutLogins.html"
+          sandbox="allow-same-origin"></iframe>
+</div>
+<pre id="test">
+</pre>
+<script>
+/** Test the login-item component **/
+
+let gLoginItem;
+const TEST_LOGIN_1 = {
+  guid: "123456789",
+  hostname: "https://example.com",
+  username: "user1",
+  password: "pass1",
+  timeCreated: "1000",
+};
+
+add_task(async function setup() {
+  let templateFrame = document.getElementById("templateFrame");
+  let displayEl = document.getElementById("display");
+  importDependencies(templateFrame, displayEl);
+
+  gLoginItem = document.createElement("login-item");
+  displayEl.appendChild(gLoginItem);
+});
+
+add_task(async function test_empty_item() {
+  ok(gLoginItem, "loginItem exists");
+  is(gLoginItem.shadowRoot.querySelector("input[name='hostname']").value, "", "hostname should be blank");
+  is(gLoginItem.shadowRoot.querySelector("input[name='username']").value, "", "username should be blank");
+  is(gLoginItem.shadowRoot.querySelector("input[name='password']").value, "", "password should be blank");
+  is(gLoginItem.shadowRoot.querySelector(".time-created").textContent, "", "time-created should be blank");
+});
+
+add_task(async function test_set_login() {
+  gLoginItem.setLogin(TEST_LOGIN_1);
+  await asyncElementRendered();
+
+  is(gLoginItem.shadowRoot.querySelector("input[name='hostname']").value, TEST_LOGIN_1.hostname, "hostname should be populated");
+  is(gLoginItem.shadowRoot.querySelector("input[name='username']").value, TEST_LOGIN_1.username, "username should be populated");
+  is(gLoginItem.shadowRoot.querySelector("input[name='password']").value, TEST_LOGIN_1.password, "password should be populated");
+  is(gLoginItem.shadowRoot.querySelector(".time-created").textContent, TEST_LOGIN_1.timeCreated, "time-created should be populated");
+});
+
+add_task(async function test_different_login_modified() {
+  let otherLogin = Object.assign({}, TEST_LOGIN_1, {username: "fakeuser", guid: "fakeguid"});
+  gLoginItem.loginModified(otherLogin);
+  await asyncElementRendered();
+
+  is(gLoginItem.shadowRoot.querySelector("input[name='hostname']").value, TEST_LOGIN_1.hostname, "hostname should be unchanged");
+  is(gLoginItem.shadowRoot.querySelector("input[name='username']").value, TEST_LOGIN_1.username, "username should be unchanged");
+  is(gLoginItem.shadowRoot.querySelector("input[name='password']").value, TEST_LOGIN_1.password, "password should be unchanged");
+  is(gLoginItem.shadowRoot.querySelector(".time-created").textContent, TEST_LOGIN_1.timeCreated, "time-created should be unchanged");
+});
+
+add_task(async function test_different_login_removed() {
+  let otherLogin = Object.assign({}, TEST_LOGIN_1, {username: "fakeuser", guid: "fakeguid"});
+  gLoginItem.loginRemoved(otherLogin);
+  await asyncElementRendered();
+
+  is(gLoginItem.shadowRoot.querySelector("input[name='hostname']").value, TEST_LOGIN_1.hostname, "hostname should be unchanged");
+  is(gLoginItem.shadowRoot.querySelector("input[name='username']").value, TEST_LOGIN_1.username, "username should be unchanged");
+  is(gLoginItem.shadowRoot.querySelector("input[name='password']").value, TEST_LOGIN_1.password, "password should be unchanged");
+  is(gLoginItem.shadowRoot.querySelector(".time-created").textContent, TEST_LOGIN_1.timeCreated, "time-created should be unchanged");
+});
+
+add_task(async function test_login_modified() {
+  let modifiedLogin = Object.assign({}, TEST_LOGIN_1, {username: "updateduser"});
+  gLoginItem.loginModified(modifiedLogin);
+  await asyncElementRendered();
+
+  is(gLoginItem.shadowRoot.querySelector("input[name='hostname']").value, modifiedLogin.hostname, "hostname should be updated");
+  is(gLoginItem.shadowRoot.querySelector("input[name='username']").value, modifiedLogin.username, "username should be updated");
+  is(gLoginItem.shadowRoot.querySelector("input[name='password']").value, modifiedLogin.password, "password should be updated");
+  is(gLoginItem.shadowRoot.querySelector(".time-created").textContent, modifiedLogin.timeCreated, "time-created should be updated");
+});
+
+add_task(async function test_login_removed() {
+  gLoginItem.loginRemoved(TEST_LOGIN_1);
+  await asyncElementRendered();
+
+  is(gLoginItem.shadowRoot.querySelector("input[name='hostname']").value, "", "hostname should be cleared");
+  is(gLoginItem.shadowRoot.querySelector("input[name='username']").value, "", "username should be cleared");
+  is(gLoginItem.shadowRoot.querySelector("input[name='password']").value, "", "password should be cleared");
+  is(gLoginItem.shadowRoot.querySelector(".time-created").textContent, "", "time-created should be cleared");
+});
+
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/components/aboutlogins/tests/mochitest/test_login_list.html
@@ -0,0 +1,109 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Test the login-list component
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test the login-list component</title>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script src="login-list-item.js"></script>
+  <script src="login-list.js"></script>
+  <script src="aboutlogins_common.js"></script>
+
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+  <p id="display">
+  </p>
+<div id="content" style="display: none">
+  <iframe id="templateFrame" src="aboutLogins.html"
+          sandbox="allow-same-origin"></iframe>
+</div>
+<pre id="test">
+</pre>
+<script>
+/** Test the login-list component **/
+
+let gLoginList;
+const TEST_LOGIN_1 = {
+  guid: "123456789",
+  hostname: "https://example.com",
+  username: "user1",
+  password: "pass1",
+};
+const TEST_LOGIN_2 = {
+  guid: "987654321",
+  hostname: "https://example.com",
+  username: "user2",
+  password: "pass2",
+};
+
+add_task(async function setup() {
+  let templateFrame = document.getElementById("templateFrame");
+  let displayEl = document.getElementById("display");
+  importDependencies(templateFrame, displayEl);
+
+  gLoginList = document.createElement("login-list");
+  displayEl.appendChild(gLoginList);
+});
+
+add_task(async function test_empty_list() {
+  ok(gLoginList, "loginList exists");
+  is(gLoginList.textContent, "", "Initially empty");
+});
+
+add_task(async function test_populated_list() {
+  gLoginList.setLogins([TEST_LOGIN_1, TEST_LOGIN_2]);
+  await asyncElementRendered();
+  let loginListItems = gLoginList.shadowRoot.querySelectorAll("login-list-item");
+  is(loginListItems.length, 2, "Both logins should be displayed");
+  is(loginListItems[0].getAttribute("guid"), TEST_LOGIN_1.guid, "login-list-item should have correct guid attribute");
+  is(loginListItems[0].shadowRoot.querySelector(".login-list-item-hostname").textContent, TEST_LOGIN_1.hostname,
+     "login-list-item hostname should match");
+  is(loginListItems[0].shadowRoot.querySelector(".login-list-item-username").textContent, TEST_LOGIN_1.username,
+     "login-list-item username should match");
+});
+
+add_task(async function test_login_modified() {
+  let modifiedLogin = Object.assign(TEST_LOGIN_1, {username: "user11"});
+  gLoginList.loginModified(modifiedLogin);
+  await asyncElementRendered();
+  let loginListItems = gLoginList.shadowRoot.querySelectorAll("login-list-item");
+  is(loginListItems.length, 2, "Both logins should be displayed");
+  is(loginListItems[0].getAttribute("guid"), TEST_LOGIN_1.guid, "login-list-item should have correct guid attribute");
+  is(loginListItems[0].shadowRoot.querySelector(".login-list-item-hostname").textContent, TEST_LOGIN_1.hostname,
+     "login-list-item hostname should match");
+  is(loginListItems[0].shadowRoot.querySelector(".login-list-item-username").textContent, modifiedLogin.username,
+     "login-list-item username should have been updated");
+  is(loginListItems[1].shadowRoot.querySelector(".login-list-item-username").textContent, TEST_LOGIN_2.username,
+     "login-list-item2 username should remain unchanged");
+});
+
+add_task(async function test_login_added() {
+  let newLogin = Object.assign({}, TEST_LOGIN_1, {username: "user22", guid: "111222"});
+  gLoginList.loginAdded(newLogin);
+  await asyncElementRendered();
+  let loginListItems = gLoginList.shadowRoot.querySelectorAll("login-list-item");
+  is(loginListItems.length, 3, "New login should be added to the list");
+  is(loginListItems[0].getAttribute("guid"), TEST_LOGIN_1.guid, "login-list-item1 should have correct guid attribute");
+  is(loginListItems[1].getAttribute("guid"), TEST_LOGIN_2.guid, "login-list-item2 should have correct guid attribute");
+  is(loginListItems[2].getAttribute("guid"), newLogin.guid, "login-list-item3 should have correct guid attribute");
+  is(loginListItems[2].shadowRoot.querySelector(".login-list-item-hostname").textContent, newLogin.hostname,
+     "login-list-item hostname should match");
+  is(loginListItems[2].shadowRoot.querySelector(".login-list-item-username").textContent, newLogin.username,
+     "login-list-item username should have been updated");
+});
+
+add_task(async function test_login_removed() {
+  gLoginList.loginRemoved({guid: "111222"});
+  await asyncElementRendered();
+  let loginListItems = gLoginList.shadowRoot.querySelectorAll("login-list-item");
+  is(loginListItems.length, 2, "New login should be removed from the list");
+  is(loginListItems[0].getAttribute("guid"), TEST_LOGIN_1.guid, "login-list-item1 should have correct guid attribute");
+  is(loginListItems[1].getAttribute("guid"), TEST_LOGIN_2.guid, "login-list-item2 should have correct guid attribute");
+});
+</script>
+
+</body>
+</html>
--- a/browser/components/contextualidentity/test/browser/browser_aboutURLs.js
+++ b/browser/components/contextualidentity/test/browser/browser_aboutURLs.js
@@ -1,15 +1,19 @@
 "use strict";
 
 // For some about: URLs, they will take more time to load and cause timeout.
 // See Bug 1270998.
 requestLongerTimeout(2);
 
 add_task(async function() {
+  await SpecialPowers.pushPrefEnv({"set": [
+    ["signon.management.page.enabled", true],
+  ]});
+
   let aboutURLs = [];
 
   // List of about: URLs that may cause problem, so we skip them in this test.
   let skipURLs = [
     // about:credits will initiate network request.
     "credits",
     // about:telemetry will fetch Telemetry asynchronously and takes longer,
     // so we skip this for now.
--- a/browser/components/originattributes/test/browser/browser_firstPartyIsolation_aboutPages.js
+++ b/browser/components/originattributes/test/browser/browser_firstPartyIsolation_aboutPages.js
@@ -1,13 +1,15 @@
 add_task(async function setup() {
   Services.prefs.setBoolPref("privacy.firstparty.isolate", true);
+  Services.prefs.setBoolPref("signon.management.page.enabled", true);
 
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref("privacy.firstparty.isolate");
+    Services.prefs.clearUserPref("signon.management.page.enabled");
   });
 });
 
 /**
  * For loading the initial about:blank in e10s mode, it will be loaded with
  * NullPrincipal, and we also test if the firstPartyDomain of the origin
  * attributes is got from the origin itself.
  */
--- a/browser/components/preferences/in-content/tests/browser_password_management.js
+++ b/browser/components/preferences/in-content/tests/browser_password_management.js
@@ -67,16 +67,20 @@ add_task(async function subdialog_cleanu
     if (savePasswordCheckBox.checked) {
       savePasswordCheckBox.click();
     }
   });
   gBrowser.removeCurrentTab();
 });
 
 add_task(async function test_openPasswordManagement_overrideURI() {
+  await SpecialPowers.pushPrefEnv({"set": [
+    ["signon.management.page.enabled", true],
+  ]});
+
   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");
--- a/toolkit/components/passwordmgr/test/browser/browser_openPasswordManager.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_openPasswordManager.js
@@ -27,16 +27,20 @@ add_task(async function test_filter() {
   ok(win, "Login dialog was opened with a domain filter");
   await BrowserTestUtils.closeWindow(win);
   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],
+  ]});
+
   Services.prefs.setStringPref(PREF_MANAGEMENT_URI, "about:logins?filter=%DOMAIN%");
   let tabOpenPromise = BrowserTestUtils.waitForNewTab(gBrowser, "about:logins?filter=");
   LoginHelper.openPasswordManager(window);
   let tab = await tabOpenPromise;
   ok(tab, "Got the new tab");
   BrowserTestUtils.removeTab(tab);
   resetPrefs();
 });