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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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