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;
6 const pdfUrl = TESTROOT + "file_pdfjs_test.pdf";
7 const caretBrowsingModePref = "accessibility.browsewithcaret";
10 add_task(async function test() {
11 let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
12 let handlerInfo = mimeService.getFromTypeAndExtension(
17 // Make sure pdf.js is the default handler.
19 handlerInfo.alwaysAskBeforeHandling,
21 "pdf handler defaults to always-ask is false"
24 handlerInfo.preferredAction,
25 Ci.nsIHandlerInfo.handleInternally,
26 "pdf handler defaults to internal"
29 info("Pref action: " + handlerInfo.preferredAction);
31 await BrowserTestUtils.withNewTab(
32 { gBrowser, url: "about:blank" },
33 async function test_caret_browsing_mode(browser) {
34 await waitForPdfJS(browser, pdfUrl);
36 let promise = BrowserTestUtils.waitForContentEvent(
43 await SpecialPowers.pushPrefEnv({
44 set: [[caretBrowsingModePref, true]],
47 await TestUtils.waitForTick();
49 await SpecialPowers.spawn(browser, [], async function () {
50 const viewer = content.wrappedJSObject.PDFViewerApplication;
52 viewer.supportsCaretBrowsingMode,
53 "Caret browsing mode is supported"
57 promise = BrowserTestUtils.waitForContentEvent(
64 await SpecialPowers.popPrefEnv();
66 await TestUtils.waitForTick();
68 await SpecialPowers.spawn(browser, [], async function () {
69 const viewer = content.wrappedJSObject.PDFViewerApplication;
71 !viewer.supportsCaretBrowsingMode,
72 "Caret browsing mode isn't supported"
76 await waitForPdfJSClose(browser);