1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/downloads/test/unit/test_guid.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,32 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +const dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager); 1.9 + 1.10 +function run_test() 1.11 +{ 1.12 + if (oldDownloadManagerDisabled()) { 1.13 + return; 1.14 + } 1.15 + 1.16 + let server = new HttpServer(); 1.17 + server.start(-1); 1.18 + let dl = addDownload(server); 1.19 + do_test_pending(); 1.20 + 1.21 + do_print(dl.guid); 1.22 + do_check_true(/^[a-zA-Z0-9\-_]{12}$/.test(dl.guid)); 1.23 + 1.24 + dm.getDownloadByGUID(dl.guid, function(status, result) { 1.25 + do_check_eq(dl, result, "should get back some download as requested"); 1.26 + dl.cancel(); 1.27 + 1.28 + dm.getDownloadByGUID("nonexistent", function(status, result) { 1.29 + do_check_eq(result, null, "should get back no download"); 1.30 + do_check_eq(Components.results.NS_ERROR_NOT_AVAILABLE, status, 1.31 + "should pass NS_ERROR_NOT_AVAILABLE on failure"); 1.32 + do_test_finished(); 1.33 + }); 1.34 + }); 1.35 +}