Follow-on fix for bug 457825. Use sheet principal for agent and user sheets. r=dbaron...
[wine-gecko.git] / netwerk / test / unit / test_bug411952.js
blob4785542aa0061829b028f6bf0752e1b2e922b221
1 const Cc = Components.classes;
2 const Ci = Components.interfaces;
4 function run_test() {
5 try {
6 var cm = Cc["@mozilla.org/cookiemanager;1"].
7 getService(Ci.nsICookieManager2);
8 do_check_neq(cm, null, "Retrieving the cookie manager failed");
10 const time = (new Date("Jan 1, 2030")).getTime() / 1000;
11 cm.add("example.com", "/", "C", "V", false, true, false, time);
12 const now = Math.floor((new Date()).getTime() / 1000);
14 var enumerator = cm.enumerator, found = false;
15 while (enumerator.hasMoreElements()) {
16 var cookie = enumerator.getNext().QueryInterface(Ci.nsICookie2);
17 if (cookie.host == "example.com" &&
18 cookie.path == "/" &&
19 cookie.name == "C") {
20 do_check_true("creationTime" in cookie,
21 "creationTime attribute is not accessible on the cookie");
22 var creationTime = Math.floor(cookie.creationTime / 1000000);
23 // allow the times to slip by one second at most,
24 // which should be fine under normal circumstances.
25 do_check_true(Math.abs(creationTime - now) <= 1,
26 "Cookie's creationTime is set incorrectly");
27 found = true;
28 break;
32 do_check_true(found, "Didn't find the cookie we were after");
33 } catch (e) {
34 do_throw("Unexpected exception: " + e.toString());
37 do_test_finished();