mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1583796 - Re-sort and render the login list when breach notifications are updated without acting like a user-initiated sort. r=sfoster
Differential Revision: https://phabricator.services.mozilla.com/D47982 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7a8544e664
commit
20802e4942
@ -171,9 +171,7 @@ export default class LoginList extends HTMLElement {
|
||||
break;
|
||||
}
|
||||
case "change": {
|
||||
this._applySort();
|
||||
this.render();
|
||||
this._list.scrollTop = 0;
|
||||
this._applySortAndScrollToTop();
|
||||
const extra = { sort_key: this._sortSelect.value };
|
||||
recordTelemetryEvent({ object: "list", method: "sort", extra });
|
||||
break;
|
||||
@ -348,11 +346,7 @@ export default class LoginList extends HTMLElement {
|
||||
const breachedSortOptionElement = this._sortSelect.namedItem("breached");
|
||||
breachedSortOptionElement.hidden = false;
|
||||
this._sortSelect.selectedIndex = breachedSortOptionElement.index;
|
||||
this._sortSelect.dispatchEvent(new CustomEvent("input", { bubbles: true }));
|
||||
this._sortSelect.dispatchEvent(
|
||||
new CustomEvent("change", { bubbles: true })
|
||||
);
|
||||
this.render();
|
||||
this._applySortAndScrollToTop();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -477,6 +471,12 @@ export default class LoginList extends HTMLElement {
|
||||
});
|
||||
}
|
||||
|
||||
_applySortAndScrollToTop() {
|
||||
this._applySort();
|
||||
this.render();
|
||||
this._list.scrollTop = 0;
|
||||
}
|
||||
|
||||
_updateVisibleLoginCount(count) {
|
||||
if (count != document.l10n.getAttributes(this._count).args.count) {
|
||||
document.l10n.setAttributes(this._count, "login-list-count", {
|
||||
|
@ -6,19 +6,23 @@ requestLongerTimeout(2);
|
||||
ChromeUtils.import("resource://testing-common/TelemetryTestUtils.jsm", this);
|
||||
ChromeUtils.import("resource://testing-common/LoginTestUtils.jsm", this);
|
||||
|
||||
EXPECTED_BREACH = {
|
||||
AddedDate: "2018-12-20T23:56:26Z",
|
||||
BreachDate: "2018-12-16",
|
||||
Domain: "breached.example.com",
|
||||
Name: "Breached",
|
||||
PwnCount: 1643100,
|
||||
DataClasses: ["Email addresses", "Usernames", "Passwords", "IP addresses"],
|
||||
_status: "synced",
|
||||
id: "047940fe-d2fd-4314-b636-b4a952ee0043",
|
||||
last_modified: "1541615610052",
|
||||
schema: "1541615609018",
|
||||
};
|
||||
|
||||
add_task(async function setup() {
|
||||
let storageChangedPromised = TestUtils.topicObserved(
|
||||
"passwordmgr-storage-changed",
|
||||
(_, data) => data == "addLogin"
|
||||
);
|
||||
TEST_LOGIN1 = Services.logins.addLogin(TEST_LOGIN1);
|
||||
await storageChangedPromised;
|
||||
storageChangedPromised = TestUtils.topicObserved(
|
||||
"passwordmgr-storage-changed",
|
||||
(_, data) => data == "addLogin"
|
||||
);
|
||||
TEST_LOGIN2 = Services.logins.addLogin(TEST_LOGIN2);
|
||||
await storageChangedPromised;
|
||||
TEST_LOGIN1 = await addLogin(TEST_LOGIN1);
|
||||
TEST_LOGIN2 = await addLogin(TEST_LOGIN2);
|
||||
TEST_LOGIN3 = await addLogin(TEST_LOGIN3);
|
||||
await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
url: "about:logins",
|
||||
@ -68,7 +72,7 @@ add_task(async function test_telemetry_events() {
|
||||
|
||||
let promiseNewTab = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
TEST_LOGIN2.origin + "/"
|
||||
TEST_LOGIN3.origin + "/"
|
||||
);
|
||||
await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() {
|
||||
let loginItem = content.document.querySelector("login-item");
|
||||
@ -76,7 +80,7 @@ add_task(async function test_telemetry_events() {
|
||||
originInput.click();
|
||||
});
|
||||
let newTab = await promiseNewTab;
|
||||
ok(true, "New tab opened to " + TEST_LOGIN2.origin);
|
||||
ok(true, "New tab opened to " + TEST_LOGIN3.origin);
|
||||
BrowserTestUtils.removeTab(newTab);
|
||||
await LoginTestUtils.telemetry.waitForEventCount(5);
|
||||
|
||||
|
@ -15,7 +15,6 @@ EXPECTED_BREACH = {
|
||||
};
|
||||
|
||||
add_task(async function setup() {
|
||||
TEST_LOGIN3.QueryInterface(Ci.nsILoginMetaInfo).timePasswordChanged = 123456;
|
||||
TEST_LOGIN3 = await addLogin(TEST_LOGIN3);
|
||||
await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
|
@ -36,7 +36,6 @@ add_task(async function test_added_login_shows_breach_warning() {
|
||||
);
|
||||
});
|
||||
|
||||
TEST_LOGIN3.QueryInterface(Ci.nsILoginMetaInfo).timePasswordChanged = 123456;
|
||||
TEST_LOGIN3 = await addLogin(TEST_LOGIN3);
|
||||
await ContentTask.spawn(browser, TEST_LOGIN3.guid, async aTestLogin3Guid => {
|
||||
let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
|
||||
|
@ -42,6 +42,7 @@ let TEST_LOGIN3 = new nsLoginInfo(
|
||||
"breachedLogin",
|
||||
"password"
|
||||
);
|
||||
TEST_LOGIN3.QueryInterface(Ci.nsILoginMetaInfo).timePasswordChanged = 123456;
|
||||
|
||||
async function addLogin(login) {
|
||||
let storageChangedPromised = TestUtils.topicObserved(
|
||||
|
@ -544,6 +544,7 @@ this.LoginTestUtils.telemetry = {
|
||||
}
|
||||
|
||||
events = events.filter(e => e[1] == category);
|
||||
dump(`Waiting for ${count} events, got ${events.length}\n`);
|
||||
return events.length == count ? events : null;
|
||||
}, "waiting for telemetry event count of: " + count);
|
||||
Assert.equal(events.length, count, "waiting for telemetry event count");
|
||||
|
Loading…
Reference in New Issue
Block a user