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 toolbarDensityPref
= "browser.uidensity";
9 // Test that changing the toolbar density pref is dispatched in pdf.js.
10 add_task(async
function test() {
11 const mimeService
= Cc
["@mozilla.org/mime;1"].getService(Ci
.nsIMIMEService
);
12 const 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_toolbar_density_dispatch(browser
) {
34 await
waitForPdfJS(browser
, pdfUrl
);
36 let promise
= BrowserTestUtils
.waitForContentEvent(
40 ({ detail
: { value
} }) => value
=== 2,
43 await SpecialPowers
.pushPrefEnv({
44 set: [[toolbarDensityPref
, 2]],
48 promise
= BrowserTestUtils
.waitForContentEvent(
52 ({ detail
: { value
} }) => value
=== 0,
55 await SpecialPowers
.popPrefEnv();
58 await
waitForPdfJSClose(browser
);