1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/test/unit/test_bug411952.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +function run_test() { 1.5 + try { 1.6 + var cm = Cc["@mozilla.org/cookiemanager;1"]. 1.7 + getService(Ci.nsICookieManager2); 1.8 + do_check_neq(cm, null, "Retrieving the cookie manager failed"); 1.9 + 1.10 + const time = (new Date("Jan 1, 2030")).getTime() / 1000; 1.11 + cm.add("example.com", "/", "C", "V", false, true, false, time); 1.12 + const now = Math.floor((new Date()).getTime() / 1000); 1.13 + 1.14 + var enumerator = cm.enumerator, found = false; 1.15 + while (enumerator.hasMoreElements()) { 1.16 + var cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2); 1.17 + if (cookie.host == "example.com" && 1.18 + cookie.path == "/" && 1.19 + cookie.name == "C") { 1.20 + do_check_true("creationTime" in cookie, 1.21 + "creationTime attribute is not accessible on the cookie"); 1.22 + var creationTime = Math.floor(cookie.creationTime / 1000000); 1.23 + // allow the times to slip by one second at most, 1.24 + // which should be fine under normal circumstances. 1.25 + do_check_true(Math.abs(creationTime - now) <= 1, 1.26 + "Cookie's creationTime is set incorrectly"); 1.27 + found = true; 1.28 + break; 1.29 + } 1.30 + } 1.31 + 1.32 + do_check_true(found, "Didn't find the cookie we were after"); 1.33 + } catch (e) { 1.34 + do_throw("Unexpected exception: " + e.toString()); 1.35 + } 1.36 + 1.37 + do_test_finished(); 1.38 +}