Bug 1942239 - Add option to explicitly enable incremental origin initialization in...
[gecko.git] / toolkit / components / pdfjs / test / browser_pdfjs_toolbar_density.js
blob14a0eb62e672fbe447efe432bf136b5b94e31b60
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(
13 "application/pdf",
14 "pdf"
17 // Make sure pdf.js is the default handler.
18 is(
19 handlerInfo.alwaysAskBeforeHandling,
20 false,
21 "pdf handler defaults to always-ask is false"
23 is(
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(
37 browser,
38 "toolbardensity",
39 true,
40 ({ detail: { value } }) => value === 2,
41 true
43 await SpecialPowers.pushPrefEnv({
44 set: [[toolbarDensityPref, 2]],
45 });
46 await promise;
48 promise = BrowserTestUtils.waitForContentEvent(
49 browser,
50 "toolbardensity",
51 false,
52 ({ detail: { value } }) => value === 0,
53 true
55 await SpecialPowers.popPrefEnv();
56 await promise;
58 await waitForPdfJSClose(browser);
61 });