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
;
8 // When the always ask pref is disabled, we expect the PDF to be simply
9 // downloaded without a prompt, so ensure the pref is enabled here.
10 Services
.prefs
.setBoolPref(
11 "browser.download.always_ask_before_handling_new_types",
14 var oldAction
= changeMimeHandler(Ci
.nsIHandlerInfo
.useSystemDefault
, true);
15 var tab
= BrowserTestUtils
.addTab(gBrowser
, TESTROOT
+ "file_pdfjs_test.pdf");
17 // Test: "Open with" dialog comes up when pdf.js is not selected as the default
20 "chrome://mozapps/content/downloads/unknownContentType.xhtml",
24 waitForExplicitFinish();
25 registerCleanupFunction(async
function () {
26 Services
.prefs
.clearUserPref(
27 "browser.download.always_ask_before_handling_new_types"
29 changeMimeHandler(oldAction
[0], oldAction
[1]);
30 gBrowser
.removeTab(tab
);
34 function addWindowListener(aURL
, aCallback
) {
35 Services
.wm
.addListener({
36 onOpenWindow(aXULWindow
) {
37 info("window opened, waiting for focus");
38 Services
.wm
.removeListener(this);
40 var domwindow
= aXULWindow
.docShell
.domWindow
;
41 waitForFocus(function () {
43 domwindow
.document
.location
.href
,
45 "should have seen the right window open"