michael@0: function run_test() { michael@0: try { michael@0: var cm = Cc["@mozilla.org/cookiemanager;1"]. michael@0: getService(Ci.nsICookieManager2); michael@0: do_check_neq(cm, null, "Retrieving the cookie manager failed"); michael@0: michael@0: const time = (new Date("Jan 1, 2030")).getTime() / 1000; michael@0: cm.add("example.com", "/", "C", "V", false, true, false, time); michael@0: const now = Math.floor((new Date()).getTime() / 1000); michael@0: michael@0: var enumerator = cm.enumerator, found = false; michael@0: while (enumerator.hasMoreElements()) { michael@0: var cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); michael@0: if (cookie.host == "example.com" && michael@0: cookie.path == "/" && michael@0: cookie.name == "C") { michael@0: do_check_true("creationTime" in cookie, michael@0: "creationTime attribute is not accessible on the cookie"); michael@0: var creationTime = Math.floor(cookie.creationTime / 1000000); michael@0: // allow the times to slip by one second at most, michael@0: // which should be fine under normal circumstances. michael@0: do_check_true(Math.abs(creationTime - now) <= 1, michael@0: "Cookie's creationTime is set incorrectly"); michael@0: found = true; michael@0: break; michael@0: } michael@0: } michael@0: michael@0: do_check_true(found, "Didn't find the cookie we were after"); michael@0: } catch (e) { michael@0: do_throw("Unexpected exception: " + e.toString()); michael@0: } michael@0: michael@0: do_test_finished(); michael@0: }