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 = "http://example.com/browser/" + RELATIVE_DIR;
7 add_task(async function test() {
8 let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
9 let handlerInfo = mimeService.getFromTypeAndExtension(
14 // Make sure pdf.js is the default handler.
16 handlerInfo.alwaysAskBeforeHandling,
18 "pdf handler defaults to always-ask is false"
21 handlerInfo.preferredAction,
22 Ci.nsIHandlerInfo.handleInternally,
23 "pdf handler defaults to internal"
26 info("Pref action: " + handlerInfo.preferredAction);
28 await BrowserTestUtils.withNewTab(
29 { gBrowser, url: "about:blank" },
30 async function (browser) {
31 // check that PDF is opened with internal viewer
32 await waitForPdfJS(browser, TESTROOT + "file_pdfjs_test.pdf");
34 await SpecialPowers.spawn(browser, [], async function () {
36 content.document.querySelector("div#viewer"),
37 "document content has viewer UI"
41 var sidebar = content.document.querySelector("#sidebarToggleButton");
43 content.document.querySelector("div#outerContainer");
47 outerContainer.classList.contains("sidebarOpen"),
48 "sidebar opens on click"
51 // check that thumbnail view is open
52 var thumbnailView = content.document.querySelector("div#thumbnailView");
53 var outlineView = content.document.querySelector("div#outlineView");
56 thumbnailView.getAttribute("class"),
58 "Initial view is thumbnail view"
61 outlineView.getAttribute("class"),
63 "Outline view is hidden initially"
66 // switch to outline view
67 var viewOutlineButton =
68 content.document.querySelector("button#viewOutline");
69 viewOutlineButton.click();
72 thumbnailView.getAttribute("class"),
74 "Thumbnail view is hidden when outline is selected"
77 outlineView.getAttribute("class"),
79 "Outline view is visible when selected"
82 // switch back to thumbnail view
83 var viewThumbnailButton = content.document.querySelector(
84 "button#viewThumbnail"
86 viewThumbnailButton.click();
89 thumbnailView.getAttribute("class"),
91 "Thumbnail view is visible when selected"
94 outlineView.getAttribute("class"),
96 "Outline view is hidden when thumbnail is selected"
102 await waitForPdfJSClose(browser);