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 // check that PDF is opened with internal viewer
35 await waitForPdfJS(browser, TESTROOT + "file_pdfjs_test.pdf");
37 await Services.fog.testFlushAllChildren();
38 Assert.equal(Glean.pdfjs.buttons.cursor_hand_tool.testGetValue() || 0, 0);
40 info("Clicking on the secondary toolbar button...");
41 await SpecialPowers.spawn(browser, [], () => {
42 content.document.querySelector("#secondaryToolbarToggleButton").click();
45 await BrowserTestUtils.waitForCondition(async () =>
46 SpecialPowers.spawn(browser, [], async function () {
47 return !content.document
48 .querySelector("#secondaryToolbar")
49 .classList.contains("hidden");
53 info("Clicking on the cursor handtool button...");
54 await SpecialPowers.spawn(browser, [], () => {
55 content.document.querySelector("#cursorHandTool").click();
58 await Services.fog.testFlushAllChildren();
59 Assert.equal(Glean.pdfjs.buttons.cursor_hand_tool.testGetValue(), 1);
61 await waitForPdfJSClose(browser);