3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script type="text/javascript">
6 function initialize_CookieTests()
9 InspectorTest.dumpCookie = function(cookie)
11 var requestDate = new Date("Mon Oct 18 2010 17:00:00 GMT+0000");
12 var expires = cookie.expiresDate(requestDate);
14 var output = "name: " + cookie.name() + ", value: " + cookie.value() + ", httpOnly: " + cookie.httpOnly() +
15 ", secure: " + cookie.secure() + ", session: " + cookie.session() + ", path: " + cookie.path() +
16 ", domain: " + cookie.domain() + ", port: " + cookie.port() +
17 ", expires: " + (expires ? expires.getTime() : "n/a") +
18 ", size: " + cookie.size();
20 InspectorTest.addResult(output);
21 InspectorTest.addObject(cookie.attributes());
24 InspectorTest.dumpCookies = function(cookies)
26 for (var i = 0; i < cookies.length; ++i)
27 InspectorTest.dumpCookie(cookies[i]);
30 InspectorTest.parseAndDumpCookie = function(header)
32 var parser = new WebInspector.CookieParser();
33 InspectorTest.addResult("source: " + header);
34 InspectorTest.dumpCookies(parser.parseCookie(header));
37 InspectorTest.parseAndDumpSetCookie = function(header)
39 var parser = new WebInspector.CookieParser();
40 InspectorTest.addResult("source: " + header);
41 InspectorTest.dumpCookies(parser.parseSetCookie(header));
48 InspectorTest.parseAndDumpCookie("cookie=value");
49 InspectorTest.parseAndDumpCookie("$version=1; a=b,c = d, e=f");
50 InspectorTest.parseAndDumpCookie("$version=1; a=b;c = d; e =f");
51 InspectorTest.parseAndDumpCookie("cooke1 = value1; another cookie = another value");
52 InspectorTest.parseAndDumpCookie("cooke1 = value; $Path=/; $Domain=.example.com;");
53 InspectorTest.parseAndDumpCookie("cooke1 = value; $Path=/; $Domain=.example.com ; Cookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com;");
54 InspectorTest.parseAndDumpCookie("cooke1 = value; $Path=/; $Domain=.example.com\nCookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com; ");
55 InspectorTest.parseAndDumpCookie("$version =1; cooke1 = value; $Path=/; $Domain =.example.com; \n Cookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com;");
57 InspectorTest.parseAndDumpSetCookie("cookie=value");
58 InspectorTest.parseAndDumpSetCookie("a=b\n c=d\n f");
59 InspectorTest.parseAndDumpSetCookie("cooke1 = value; Path=/; Domain=.example.com;");
60 InspectorTest.parseAndDumpSetCookie("cooke1 = value; Path=/; Domain= .example.com \nCookie2 = value2; Path = /foo; Domain = foo.example.com");
61 InspectorTest.parseAndDumpSetCookie("cooke1 = value; expires = Mon, Oct 18 2010 17:00 GMT+0000; Domain =.example.com\nCookie2 = value2; Path = /foo; DOMAIN = foo.example.com; HttpOnly; Secure; Discard;");
62 InspectorTest.parseAndDumpSetCookie("cooke1 = value; max-age= 1440; Domain =.example.com\n Cookie2 = value2; Path = /foo; DOMAIN = foo.example.com; HttpOnly; Secure; Discard;");
63 InspectorTest.parseAndDumpSetCookie("cooke1; Path=/; Domain=.example.com;");
64 InspectorTest.parseAndDumpSetCookie("cooke1=; Path=/; Domain=.example.com;");
65 InspectorTest.completeTest();
70 <body onload="runTest()">
71 <p>Tests inspector cookie parser</p>