toolkit/components/downloads/test/unit/test_guid.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

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 }

mercurial