summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/browser/browser_entry_point_telemetry.js
blob: 9241f186120fddceec8db7284e90fcc29a643b46 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const TEST_ORIGIN = "https://example.com";

add_setup(async function () {
  await SpecialPowers.pushPrefEnv({
    set: [["signon.rememberSignons.visibilityToggle", true]],
  });
  Services.telemetry.clearEvents();
});

add_task(async function mainMenu_entryPoint() {
  await SimpleTest.promiseFocus();
  info("mainMenu_entryPoint, got focus");

  let mainMenu = document.getElementById("appMenu-popup");
  let target = document.getElementById("PanelUI-menu-button");
  await TestUtils.waitForCondition(
    () => BrowserTestUtils.isVisible(target),
    "Main menu button should be visible."
  );
  info("mainMenu_entryPoint, Main menu button is visible");
  Assert.equal(
    mainMenu.state,
    "closed",
    `Menu panel (${mainMenu.id}) is initally closed.`
  );

  info("mainMenu_entryPoint, clicking target and waiting for popup");
  let popupshown = BrowserTestUtils.waitForEvent(mainMenu, "popupshown");
  EventUtils.synthesizeMouseAtCenter(target, {});
  await popupshown;

  info("mainMenu_entryPoint, main menu popup is shown");
  Assert.equal(mainMenu.state, "open", `Menu panel (${mainMenu.id}) is open.`);

  let loginsButtonID = "appMenu-passwords-button";

  let item = document.getElementById(loginsButtonID);
  await TestUtils.waitForCondition(
    () => BrowserTestUtils.isVisible(item),
    "Logins and passwords button is visible."
  );

  info("mainMenu_entryPoint, clicking on Logins and passwords button");
  let openingFunc = () => EventUtils.synthesizeMouseAtCenter(item, {});
  let passwordManager = await openPasswordManager(openingFunc);
  info("mainMenu_entryPoint, password manager dialog shown");

  await LoginTestUtils.telemetry.waitForEventCount(1);
  TelemetryTestUtils.assertEvents(
    [["pwmgr", "open_management", "mainmenu"]],
    {
      category: "pwmgr",
      method: "open_management",
    },
    { clear: true, process: "content" }
  );

  info("mainMenu_entryPoint, close dialog and main menu");
  await passwordManager.close();
  mainMenu.hidePopup();
});

add_task(async function pageInfo_entryPoint() {
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: TEST_ORIGIN,
    },
    async function (_browser) {
      info("pageInfo_entryPoint, opening pageinfo");
      let pageInfo = BrowserPageInfo(TEST_ORIGIN, "securityTab", {});
      await BrowserTestUtils.waitForEvent(pageInfo, "page-info-init");
      info(
        "pageInfo_entryPoint, got pageinfo, wait until password button is visible"
      );
      let passwordsButton = pageInfo.document.getElementById(
        "security-view-password"
      );

      await TestUtils.waitForCondition(
        () => BrowserTestUtils.isVisible(passwordsButton),
        "Show passwords button should be visible."
      );
      info("pageInfo_entryPoint, clicking the show passwords button...");
      await SimpleTest.promiseFocus(pageInfo);
      let openingFunc = () =>
        EventUtils.synthesizeMouseAtCenter(passwordsButton, {}, pageInfo);

      info("pageInfo_entryPoint, waiting for the passwords manager dialog");
      let passwordManager = await openPasswordManager(openingFunc);

      TelemetryTestUtils.assertEvents(
        [["pwmgr", "open_management", "pageinfo"]],
        { category: "pwmgr", method: "open_management" },
        { clear: true, process: "content" }
      );

      info("pageInfo_entryPoint, close dialog and pageInfo");
      await passwordManager.close();
      pageInfo.close();
    }
  );
});