diff --git a/browser/components/aboutlogins/content/components/login-item.js b/browser/components/aboutlogins/content/components/login-item.js index 8a16be4deb67..e083430c2320 100644 --- a/browser/components/aboutlogins/content/components/login-item.js +++ b/browser/components/aboutlogins/content/components/login-item.js @@ -96,7 +96,7 @@ export default class LoginItem extends HTMLElement { this.render(); - this._breachAlertLink.addEventListener("click", this); + this._breachAlertLearnMoreLink.addEventListener("click", this); this._cancelButton.addEventListener("click", this); this._copyPasswordButton.addEventListener("click", this); this._copyUsernameButton.addEventListener("click", this); @@ -110,6 +110,7 @@ export default class LoginItem extends HTMLElement { this._originInput.addEventListener("auxclick", this); this._originDisplayInput.addEventListener("click", this); this._revealCheckbox.addEventListener("click", this); + this._vulnerableAlertLearnMoreLink.addEventListener("click", this); window.addEventListener("AboutLoginsInitialLoginSelected", this); window.addEventListener("AboutLoginsLoadInitialFavicon", this); window.addEventListener("AboutLoginsLoginSelected", this); @@ -492,14 +493,17 @@ export default class LoginItem extends HTMLElement { if (classList.contains("origin-input")) { this._handleOriginClick(); } - if (classList.contains("alert-link")) { + if (classList.contains("alert-learn-more-link")) { if (event.currentTarget.closest(".breach-alert")) { this._recordTelemetryEvent({ object: "existing_login", method: "learn_more_breach", }); } else if (event.currentTarget.closest(".vulnerable-alert")) { - // TODO: Add telemetry event + this._recordTelemetryEvent({ + object: "existing_login", + method: "learn_more_vuln", + }); } } break; diff --git a/browser/components/aboutlogins/tests/browser/browser_aaa_eventTelemetry_run_first.js b/browser/components/aboutlogins/tests/browser/browser_aaa_eventTelemetry_run_first.js index bfc7d500cce2..ae13ab2e7ae0 100644 --- a/browser/components/aboutlogins/tests/browser/browser_aaa_eventTelemetry_run_first.js +++ b/browser/components/aboutlogins/tests/browser/browser_aaa_eventTelemetry_run_first.js @@ -63,6 +63,29 @@ add_task(async function test_telemetry_events() { }); await LoginTestUtils.telemetry.waitForEventCount(2); + // Need to change the learn-more to a local address for testing. + const FAKE_LEARN_MORE_URL = "https://learn-more.example.com/"; + let promiseNewTab = BrowserTestUtils.waitForNewTab( + gBrowser, + FAKE_LEARN_MORE_URL + ); + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [FAKE_LEARN_MORE_URL], + async function(fakeLearnMoreUrl) { + let loginItem = content.document.querySelector("login-item"); + let learnMoreLink = loginItem.shadowRoot.querySelector( + ".alert-learn-more-link" + ); + learnMoreLink.href = fakeLearnMoreUrl; + learnMoreLink.click(); + } + ); + let newTab = await promiseNewTab; + ok(true, "New tab opened to " + FAKE_LEARN_MORE_URL); + BrowserTestUtils.removeTab(newTab); + await LoginTestUtils.telemetry.waitForEventCount(3); + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() { let loginItem = content.document.querySelector("login-item"); let copyButton = loginItem.shadowRoot.querySelector( @@ -70,7 +93,7 @@ add_task(async function test_telemetry_events() { ); copyButton.click(); }); - await LoginTestUtils.telemetry.waitForEventCount(3); + await LoginTestUtils.telemetry.waitForEventCount(4); if (OSKeyStoreTestUtils.canTestOSKeyStoreLogin()) { let reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true); @@ -85,13 +108,13 @@ add_task(async function test_telemetry_events() { // When reauth is observed an extra telemetry event will be recorded // for the reauth, hence the event count increasing by 2 here, and later // in the test as well. - await LoginTestUtils.telemetry.waitForEventCount(5); + await LoginTestUtils.telemetry.waitForEventCount(6); } let nextTelemetryEventCount = OSKeyStoreTestUtils.canTestOSKeyStoreLogin() - ? 6 - : 4; + ? 7 + : 5; - let promiseNewTab = BrowserTestUtils.waitForNewTab( + promiseNewTab = BrowserTestUtils.waitForNewTab( gBrowser, TEST_LOGIN3.origin + "/" ); @@ -100,7 +123,7 @@ add_task(async function test_telemetry_events() { let originInput = loginItem.shadowRoot.querySelector(".origin-input"); originInput.click(); }); - let newTab = await promiseNewTab; + newTab = await promiseNewTab; ok(true, "New tab opened to " + TEST_LOGIN3.origin); BrowserTestUtils.removeTab(newTab); await LoginTestUtils.telemetry.waitForEventCount(nextTelemetryEventCount++); @@ -240,6 +263,14 @@ add_task(async function test_telemetry_events() { let expectedEvents = [ [true, "pwmgr", "open_management", "direct"], [true, "pwmgr", "select", "existing_login", null, { breached: "true" }], + [ + true, + "pwmgr", + "learn_more_breach", + "existing_login", + null, + { breached: "true" }, + ], [true, "pwmgr", "copy", "username", null, { breached: "true" }], [testOSAuth, "pwmgr", "reauthenticate", "os_auth", "success"], [testOSAuth, "pwmgr", "copy", "password", null, { breached: "true" }], diff --git a/toolkit/components/telemetry/Events.yaml b/toolkit/components/telemetry/Events.yaml index cbf0f750684b..eb1c57b7782d 100644 --- a/toolkit/components/telemetry/Events.yaml +++ b/toolkit/components/telemetry/Events.yaml @@ -654,6 +654,7 @@ pwmgr: "filter", "hide", "learn_more_breach", + "learn_more_vuln", "new", "open_site", "save", @@ -665,6 +666,7 @@ pwmgr: - 1548463 - 1600958 - 1549115 + - 1628165 expiry_version: never notification_emails: ["loines@mozilla.com", "passwords-dev@mozilla.org", "jaws@mozilla.com"] release_channel_collection: opt-out