michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() michael@0: { michael@0: try { michael@0: if (Services.prefs.getBoolPref("browser.download.useJSTransfer")) { michael@0: return; michael@0: } michael@0: } catch (ex) { } michael@0: michael@0: const PREF_BDM_CLOSEWHENDONE = "browser.download.manager.closeWhenDone"; michael@0: var dm = Cc["@mozilla.org/download-manager;1"]. michael@0: getService(Ci.nsIDownloadManager); michael@0: var db = dm.DBConnection; michael@0: michael@0: // First, we clean up the DM michael@0: db.executeSimpleSQL("DELETE FROM moz_downloads"); michael@0: michael@0: // See if the DM is already open, and if it is, close it! michael@0: var win = Services.wm.getMostRecentWindow("Download:Manager"); michael@0: if (win) michael@0: win.close(); michael@0: michael@0: // We need to set browser.download.manager.closeWhenDone to true to test this michael@0: Services.prefs.setBoolPref(PREF_BDM_CLOSEWHENDONE, true); michael@0: michael@0: // register a callback to add a load listener to know when the download michael@0: // manager opens michael@0: Services.ww.registerNotification(function (aSubject, aTopic, aData) { michael@0: Services.ww.unregisterNotification(arguments.callee); michael@0: michael@0: var win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); michael@0: win.addEventListener("DOMContentLoaded", finishUp, false); michael@0: }); michael@0: michael@0: // The window doesn't open once we call show, so we need to wait a little bit michael@0: function finishUp() { michael@0: var dmui = Cc["@mozilla.org/download-manager-ui;1"]. michael@0: getService(Ci.nsIDownloadManagerUI); michael@0: ok(dmui.visible, "Download Manager window is open, as expected."); michael@0: michael@0: // Reset the pref to its default value michael@0: try { michael@0: Services.prefs.clearUserPref(PREF_BDM_CLOSEWHENDONE); michael@0: } michael@0: catch (err) { } michael@0: michael@0: finish(); michael@0: } michael@0: michael@0: // OK, let's pull up the UI michael@0: // Linux uses y, everything else is j michael@0: var key = navigator.platform.match("Linux") ? "y" : "j"; michael@0: EventUtils.synthesizeKey(key, {metaKey: true}, window.opener); michael@0: michael@0: waitForExplicitFinish(); michael@0: }