Bug 1941046 - Part 4: Send a callback request for impression and clicks of MARS Top...
[gecko.git] / toolkit / components / pdfjs / test / browser_pdfjs_load_telemetry.js
blob0f77bbbb44360f6294dcd0fb4e0635718d212e8f
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 const RELATIVE_DIR = "toolkit/components/pdfjs/test/";
5 const TESTROOT = "https://example.com/browser/" + RELATIVE_DIR;
7 // Test telemetry.
8 add_task(async function test() {
9 let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
10 let handlerInfo = mimeService.getFromTypeAndExtension(
11 "application/pdf",
12 "pdf"
15 // Make sure pdf.js is the default handler.
16 is(
17 handlerInfo.alwaysAskBeforeHandling,
18 false,
19 "pdf handler defaults to always-ask is false"
21 is(
22 handlerInfo.preferredAction,
23 Ci.nsIHandlerInfo.handleInternally,
24 "pdf handler defaults to internal"
27 info("Pref action: " + handlerInfo.preferredAction);
29 await BrowserTestUtils.withNewTab(
30 { gBrowser, url: "about:blank" },
31 async function (browser) {
32 Services.fog.testResetFOG();
34 await Services.fog.testFlushAllChildren();
35 Assert.equal(Glean.pdfjs.timeToView.testGetValue(), undefined);
36 Assert.equal(Glean.pdfjs.used.testGetValue() || 0, 0);
38 // check that PDF is opened with internal viewer
39 await waitForPdfJS(browser, TESTROOT + "file_pdfjs_test.pdf");
41 await Services.fog.testFlushAllChildren();
42 Assert.ok(Glean.pdfjs.timeToView.testGetValue().sum !== 0);
43 Assert.equal(Glean.pdfjs.used.testGetValue(), 1);
45 await waitForPdfJSClose(browser);
48 });