Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 1ae6d70

Browse files
author
Micah Tigley
committed
Bug 1945083 - [contextual-password-manager] Ensure password is concealed when rebuilding snapshots. r=rsafaeian,credential-management-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D236601
1 parent 6c0d7c2 commit 1ae6d70

File tree

4 files changed

+65
-11
lines changed

4 files changed

+65
-11
lines changed

toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ export class DataSourceBase {
339339
i < this.lines.length &&
340340
currentRecord == this.lines[i].record
341341
) {
342+
this.lines[i].concealed = true;
342343
yield this.lines[i];
343344
i += 1;
344345
}
@@ -357,6 +358,7 @@ export class DataSourceBase {
357358
// No search text is provided - send all lines out, count records
358359
let currentRecord;
359360
for (const line of this.lines) {
361+
line.concealed = true;
360362
yield line;
361363

362364
if (line.record != currentRecord) {

toolkit/components/satchel/megalist/content/tests/browser/browser_passwords_create_login.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@ function addLogin(megalist, { origin, username, password }) {
3636
saveButton.buttonEl.click();
3737
}
3838

39-
function waitForSnapshots() {
40-
info("Wait for headers.");
41-
const sidebar = document.getElementById("sidebar");
42-
const megalistComponent =
43-
sidebar.contentDocument.querySelector("megalist-alpha");
44-
return BrowserTestUtils.waitForCondition(
45-
() => megalistComponent.header,
46-
"Megalist header loaded."
47-
);
48-
}
49-
5039
function waitForPopup(megalist, element) {
5140
info(`Wait for ${element} popup`);
5241
const loginForm = megalist.querySelector("login-form");

toolkit/components/satchel/megalist/content/tests/browser/browser_passwords_sidebar.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ function checkPasswordCardFields(megalist) {
5050
}
5151
}
5252

53+
async function waitForPasswordConceal(passwordLine) {
54+
const concealedPromise = BrowserTestUtils.waitForMutationCondition(
55+
passwordLine,
56+
{
57+
attributeFilter: ["inputtype"],
58+
},
59+
() => passwordLine.loginLine.getAttribute("inputtype") === "password"
60+
);
61+
return concealedPromise;
62+
}
63+
5364
add_setup(async function () {
5465
await SpecialPowers.pushPrefEnv({
5566
set: [
@@ -154,6 +165,7 @@ add_task(async function test_login_line_commands() {
154165

155166
add_task(async function test_passwords_menu_external_links() {
156167
const passwordsSidebar = await openPasswordsSidebar();
168+
await waitForSnapshots();
157169
const menu = passwordsSidebar.querySelector("panel-list");
158170
const menuButton = passwordsSidebar.querySelector("#more-options-menubutton");
159171

@@ -200,6 +212,7 @@ async function waitForMigrationWizard() {
200212

201213
add_task(async function test_passwords_menu_import_from_browser() {
202214
const passwordsSidebar = await openPasswordsSidebar();
215+
await waitForSnapshots();
203216
const menu = passwordsSidebar.querySelector("panel-list");
204217
const menuButton = passwordsSidebar.querySelector("#more-options-menubutton");
205218

@@ -214,3 +227,42 @@ add_task(async function test_passwords_menu_import_from_browser() {
214227
BrowserTestUtils.removeTab(gBrowser.selectedTab);
215228
SidebarController.hide();
216229
});
230+
231+
add_task(async function test_passwords_visibility_when_view_shown() {
232+
const login = TEST_LOGIN_1;
233+
await LoginTestUtils.addLogin(login);
234+
235+
let megalist = await openPasswordsSidebar();
236+
await checkAllLoginsRendered(megalist);
237+
238+
info("Test that reopening the sidebar should have password concealed.");
239+
let passwordCard = megalist.querySelector("password-card");
240+
await waitForReauth(async () => {
241+
return await waitForPasswordReveal(passwordCard.passwordLine);
242+
});
243+
244+
info("Hide the sidebar");
245+
SidebarController.hide();
246+
await BrowserTestUtils.waitForCondition(() => {
247+
return !SidebarController.isOpen;
248+
}, "Sidebar did not close.");
249+
250+
info("Open sidebar and check visibility of password field");
251+
megalist = await openPasswordsSidebar();
252+
await checkAllLoginsRendered(megalist);
253+
passwordCard = megalist.querySelector("password-card");
254+
await waitForPasswordConceal(passwordCard.passwordLine);
255+
ok(true, "Password is hidden.");
256+
257+
info(
258+
"Test that switching panels then switching back to Passwords should have password concealed."
259+
);
260+
await SidebarController.show("viewBookmarksSidebar");
261+
megalist = await openPasswordsSidebar();
262+
await checkAllLoginsRendered(megalist);
263+
passwordCard = megalist.querySelector("password-card");
264+
await waitForPasswordConceal(passwordCard.passwordLine);
265+
ok(true, "Password is hidden.");
266+
267+
SidebarController.hide();
268+
});

toolkit/components/satchel/megalist/content/tests/browser/head.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,14 @@ function waitForPasswordReveal(passwordLine) {
210210
passwordLine.revealBtn.click();
211211
return revealBtnPromise;
212212
}
213+
214+
function waitForSnapshots() {
215+
info("Wait for headers.");
216+
const sidebar = document.getElementById("sidebar");
217+
const megalistComponent =
218+
sidebar.contentDocument.querySelector("megalist-alpha");
219+
return BrowserTestUtils.waitForCondition(
220+
() => megalistComponent.header,
221+
"Megalist header loaded."
222+
);
223+
}

0 commit comments

Comments
 (0)