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
;
8 add_task(async
function test() {
9 let mimeService
= Cc
["@mozilla.org/mime;1"].getService(Ci
.nsIMIMEService
);
10 let handlerInfo
= mimeService
.getFromTypeAndExtension(
15 // Make sure pdf.js is the default handler.
17 handlerInfo
.alwaysAskBeforeHandling
,
19 "pdf handler defaults to always-ask is false"
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
);