netwerk/test/unit/test_bug411952.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 function run_test() {
     2   try {
     3     var cm = Cc["@mozilla.org/cookiemanager;1"].
     4              getService(Ci.nsICookieManager2);
     5     do_check_neq(cm, null, "Retrieving the cookie manager failed");
     7     const time = (new Date("Jan 1, 2030")).getTime() / 1000;
     8     cm.add("example.com", "/", "C", "V", false, true, false, time);
     9     const now = Math.floor((new Date()).getTime() / 1000);
    11     var enumerator = cm.enumerator, found = false;
    12     while (enumerator.hasMoreElements()) {
    13       var cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
    14       if (cookie.host == "example.com" &&
    15           cookie.path == "/" &&
    16           cookie.name == "C") {
    17         do_check_true("creationTime" in cookie,
    18           "creationTime attribute is not accessible on the cookie");
    19         var creationTime = Math.floor(cookie.creationTime / 1000000);
    20         // allow the times to slip by one second at most,
    21         // which should be fine under normal circumstances.
    22         do_check_true(Math.abs(creationTime - now) <= 1,
    23           "Cookie's creationTime is set incorrectly");
    24         found = true;
    25         break;
    26       }
    27     }
    29     do_check_true(found, "Didn't find the cookie we were after");
    30   } catch (e) {
    31     do_throw("Unexpected exception: " + e.toString());
    32   }
    34   do_test_finished();
    35 }

mercurial