Bug 1592467 - Add some basic tests for checking that the vulnerable login banner is displayed. r=sfoster
☠☠ backed out by 62b434d3602a ☠ ☠
authorJared Wein <jwein@mozilla.com>
Fri, 27 Mar 2020 02:28:54 +0000
changeset 520690 b353abb5f07fd48e7957653dbc4c05ddfdd1544f
parent 520689 c64620a2abf9294639555543dd83b94408a51cb2
child 520691 7f78c8fb5c6ea19dead7752c068f00d96658e3a0
push id111253
push userjwein@mozilla.com
push dateFri, 27 Mar 2020 02:31:31 +0000
treeherderautoland@7f78c8fb5c6e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs1592467
milestone76.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 1592467 - Add some basic tests for checking that the vulnerable login banner is displayed. r=sfoster Differential Revision: https://phabricator.services.mozilla.com/D68109
browser/components/aboutlogins/tests/chrome/test_login_item.html
--- a/browser/components/aboutlogins/tests/chrome/test_login_item.html
+++ b/browser/components/aboutlogins/tests/chrome/test_login_item.html
@@ -50,16 +50,19 @@ const TEST_LOGIN_2 = {
 const TEST_BREACH = {
   Name: "Test-Breach",
   breachAlertURL: "https://monitor.firefox.com/breach-details/Test-Breach",
 };
 
 const TEST_BREACHES_MAP = new Map();
 TEST_BREACHES_MAP.set(TEST_LOGIN_1.guid, TEST_BREACH);
 
+const TEST_VULNERABLE_MAP = new Map();
+TEST_VULNERABLE_MAP.set(TEST_LOGIN_2.guid, true);
+
 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);
 
@@ -131,25 +134,54 @@ add_task(async function test_update_brea
   gLoginItem.setLogin(TEST_LOGIN_1);
   gLoginItem.setBreaches(TEST_BREACHES_MAP);
   await asyncElementRendered();
 
   let correspondingBreach = TEST_BREACHES_MAP.get(gLoginItem._login.guid);
   let breachAlert = gLoginItem.shadowRoot.querySelector(".breach-alert");
   ok(!isHidden(breachAlert), "Breach alert should be visible");
   is(breachAlert.querySelector(".alert-learn-more-link").getAttribute("href"), correspondingBreach.breachAlertURL, "Breach alert link should be equal to the correspondingBreach.breachAlertURL.");
+  is(breachAlert.querySelector(".alert-link").href, TEST_LOGIN_1.origin + "/", "Link in the text should point to the login origin");
+  let vulernableAlert = gLoginItem.shadowRoot.querySelector(".vulnerable-alert");
+  ok(isHidden(vulernableAlert), "Vulnerable alert should not be visible on a non-vulnerable login.");
 });
 
 add_task(async function test_breach_alert_is_correctly_hidden() {
   gLoginItem.setLogin(TEST_LOGIN_2);
   gLoginItem.setBreaches(TEST_BREACHES_MAP);
   await asyncElementRendered();
 
   let breachAlert = gLoginItem.shadowRoot.querySelector(".breach-alert");
   ok(isHidden(breachAlert), "Breach alert should not be visible on login without an associated breach.");
+  let vulernableAlert = gLoginItem.shadowRoot.querySelector(".vulnerable-alert");
+  ok(isHidden(vulernableAlert), "Vulnerable alert should not be visible on a non-vulnerable login.");
+});
+
+add_task(async function test_update_vulnerable() {
+  gLoginItem.setLogin(TEST_LOGIN_2);
+  gLoginItem.setVulnerableLogins(TEST_VULNERABLE_MAP);
+  await asyncElementRendered();
+
+  let breachAlert = gLoginItem.shadowRoot.querySelector(".breach-alert");
+  ok(isHidden(breachAlert), "Breach alert should not be visible on login without an associated breach.");
+  let vulernableAlert = gLoginItem.shadowRoot.querySelector(".vulnerable-alert");
+  ok(!isHidden(vulernableAlert), "Vulnerable alert should be visible");
+  is(vulernableAlert.querySelector(".alert-link").href, TEST_LOGIN_2.origin + "/", "Link in the text should point to the login origin");
+});
+
+add_task(async function test_vulnerable_alert_is_correctly_hidden() {
+  gLoginItem.setLogin(TEST_LOGIN_1);
+  gLoginItem.setVulnerableLogins(TEST_VULNERABLE_MAP);
+  gLoginItem.setBreaches(new Map());
+  await asyncElementRendered();
+
+  let breachAlert = gLoginItem.shadowRoot.querySelector(".breach-alert");
+  ok(isHidden(breachAlert), "Breach alert should not be visible on login without an associated breach.");
+  let vulernableAlert = gLoginItem.shadowRoot.querySelector(".vulnerable-alert");
+  ok(isHidden(vulernableAlert), "Vulnerable alert should not be visible on a non-vulnerable login.");
 });
 
 add_task(async function test_edit_login() {
   gLoginItem.setLogin(TEST_LOGIN_1);
   let usernameInput = gLoginItem.shadowRoot.querySelector("input[name='username']");
   usernameInput.placeholder = "dummy placeholder";
   gLoginItem.shadowRoot.querySelector(".edit-button").click();
   await asyncElementRendered();