Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 const dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
7 function run_test()
8 {
9 if (oldDownloadManagerDisabled()) {
10 return;
11 }
13 let server = new HttpServer();
14 server.start(-1);
15 let dl = addDownload(server);
16 do_test_pending();
18 do_print(dl.guid);
19 do_check_true(/^[a-zA-Z0-9\-_]{12}$/.test(dl.guid));
21 dm.getDownloadByGUID(dl.guid, function(status, result) {
22 do_check_eq(dl, result, "should get back some download as requested");
23 dl.cancel();
25 dm.getDownloadByGUID("nonexistent", function(status, result) {
26 do_check_eq(result, null, "should get back no download");
27 do_check_eq(Components.results.NS_ERROR_NOT_AVAILABLE, status,
28 "should pass NS_ERROR_NOT_AVAILABLE on failure");
29 do_test_finished();
30 });
31 });
32 }