summaryrefslogtreecommitdiffstats
path: root/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_password_reveal.js
blob: 503d421da7f88e83fb3e9ecc4e7f8140e4bfce59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function test_hidden_reveal_password() {
  await setupPolicyEngineWithJson({
    policies: {
      DisablePasswordReveal: true,
    },
  });

  let aboutLoginsTab = await BrowserTestUtils.openNewForegroundTab({
    gBrowser,
    url: "about:logins",
  });

  let browser = gBrowser.selectedBrowser;

  await SpecialPowers.spawn(browser, [], () => {
    let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
    let createButton = loginList._createLoginButton;
    ok(
      !createButton.disabled,
      "Create button should not be disabled initially"
    );
    let loginItem = Cu.waiveXrays(content.document.querySelector("login-item"));

    createButton.click();

    let passwordReveal = loginItem.shadowRoot.querySelector(
      ".reveal-password-checkbox"
    );
    is(passwordReveal.hidden, true, "Password reveal button should be hidden");

    // Bug 1696948
    let passwordInput = loginItem.shadowRoot.querySelector(
      "input[name='password']"
    );
    isnot(passwordInput, null, "Password field should be in the DOM");
  });
  BrowserTestUtils.removeTab(aboutLoginsTab);
});