diff options
Diffstat (limited to 'comm/mailnews/db/msgdb/test/unit/test_mailTelemetry.js')
-rw-r--r-- | comm/mailnews/db/msgdb/test/unit/test_mailTelemetry.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/comm/mailnews/db/msgdb/test/unit/test_mailTelemetry.js b/comm/mailnews/db/msgdb/test/unit/test_mailTelemetry.js new file mode 100644 index 0000000000..c0bc034bad --- /dev/null +++ b/comm/mailnews/db/msgdb/test/unit/test_mailTelemetry.js @@ -0,0 +1,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." + ); +}); |