/* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ const RELATIVE_DIR = "browser/extensions/pdfjs/test/"; const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR; function test() { var tab; const Cc = Components.classes; const Ci = Components.interfaces; let handlerService = Cc["@mozilla.org/uriloader/handler-service;1"].getService(Ci.nsIHandlerService); let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService); let handlerInfo = mimeService.getFromTypeAndExtension('application/pdf', 'pdf'); // // Test: Default mime handler // is(handlerInfo.alwaysAskBeforeHandling, true, 'mime handler: default is always-ask prompt'); // // Test: "Open with" dialog comes up // addWindowListener('chrome://mozapps/content/downloads/unknownContentType.xul', finish); waitForExplicitFinish(); registerCleanupFunction(function() { gBrowser.removeTab(tab); }); tab = gBrowser.addTab(TESTROOT + "file_pdfjs_test.pdf"); var newTabBrowser = gBrowser.getBrowserForTab(tab); } function addWindowListener(aURL, aCallback) { Services.wm.addListener({ onOpenWindow: function(aXULWindow) { info("window opened, waiting for focus"); Services.wm.removeListener(this); var domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindow); waitForFocus(function() { is(domwindow.document.location.href, aURL, "should have seen the right window open"); domwindow.close(); aCallback(); }, domwindow); }, onCloseWindow: function(aXULWindow) { }, onWindowTitleChange: function(aXULWindow, aNewTitle) { } }); }