summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/db/msgdb/test/unit/test_mailTelemetry.js
blob: c0bc034bad4ecb52f8030de3c6535abacaed0428 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Test telemetry related to mails read.
 */

let { TelemetryTestUtils } = ChromeUtils.importESModule(
  "resource://testing-common/TelemetryTestUtils.sys.mjs"
);

/**
 * Check that we're counting mails read.
 */
add_task(async function test_mails_read() {
  Services.telemetry.clearScalars();

  localAccountUtils.loadLocalMailAccount();

  const NUM_MAILS = 5;
  let headers =
    "from: alice@t1.example.com\r\n" +
    "to: bob@t2.example.net\r\n" +
    "return-path: alice@t1.example.com\r\n" +
    "Disposition-Notification-To: alice@t1.example.com\r\n";
  for (let i = 0; i < NUM_MAILS; i++) {
    localAccountUtils.inboxFolder.addMessage(
      "From \r\n" + headers + "\r\nhello\r\n"
    );
  }
  localAccountUtils.inboxFolder.markAllMessagesRead(null);
  const scalars = TelemetryTestUtils.getProcessScalars("parent");
  Assert.equal(
    scalars["tb.mails.read"],
    NUM_MAILS,
    "Count of mails read must be correct."
  );
});