browser_pdf_disabled.js (1636B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // This test checks that pdf always appears in the applications list even 5 // both a customized handler doesn't exist and when the internal viewer is 6 // not enabled. 7 add_task(async function pdfIsAlwaysPresent() { 8 // Try again with the pdf viewer enabled and disabled. 9 for (let test of ["enabled", "disabled"]) { 10 await SpecialPowers.pushPrefEnv({ 11 set: [["pdfjs.disabled", test == "disabled"]], 12 }); 13 14 await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true }); 15 16 let win = gBrowser.selectedBrowser.contentWindow; 17 18 let container = win.document.getElementById("handlersView"); 19 20 // First, find the PDF item. 21 let pdfItem = container.querySelector( 22 "richlistitem[type='application/pdf']" 23 ); 24 Assert.ok(pdfItem, "pdfItem is present in handlersView when " + test); 25 if (pdfItem) { 26 pdfItem.scrollIntoView({ block: "center" }); 27 pdfItem.closest("richlistbox").selectItem(pdfItem); 28 29 // Open its menu 30 let list = pdfItem.querySelector(".actionsMenu"); 31 let popup = list.menupopup; 32 let popupShown = BrowserTestUtils.waitForEvent(popup, "popupshown"); 33 EventUtils.synthesizeMouseAtCenter(list, {}, win); 34 await popupShown; 35 36 let handleInternallyItem = list.querySelector( 37 `menuitem[action='${Ci.nsIHandlerInfo.handleInternally}']` 38 ); 39 40 is( 41 test == "enabled", 42 !!handleInternallyItem, 43 "handle internally is present when " + test 44 ); 45 } 46 47 gBrowser.removeCurrentTab(); 48 } 49 });