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: const dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager); michael@0: michael@0: function run_test() michael@0: { michael@0: if (oldDownloadManagerDisabled()) { michael@0: return; michael@0: } michael@0: michael@0: let server = new HttpServer(); michael@0: server.start(-1); michael@0: let dl = addDownload(server); michael@0: do_test_pending(); michael@0: michael@0: do_print(dl.guid); michael@0: do_check_true(/^[a-zA-Z0-9\-_]{12}$/.test(dl.guid)); michael@0: michael@0: dm.getDownloadByGUID(dl.guid, function(status, result) { michael@0: do_check_eq(dl, result, "should get back some download as requested"); michael@0: dl.cancel(); michael@0: michael@0: dm.getDownloadByGUID("nonexistent", function(status, result) { michael@0: do_check_eq(result, null, "should get back no download"); michael@0: do_check_eq(Components.results.NS_ERROR_NOT_AVAILABLE, status, michael@0: "should pass NS_ERROR_NOT_AVAILABLE on failure"); michael@0: do_test_finished(); michael@0: }); michael@0: }); michael@0: }