summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector/cookie-parser.html
blob: 8dd2ed76f22739ea6373776c42ee62fde0b2fcba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script type="text/javascript">

function initialize_CookieTests()
{

InspectorTest.dumpCookie = function(cookie)
{
    var requestDate = new Date("Mon Oct 18 2010 17:00:00 GMT+0000");
    var expires = cookie.expiresDate(requestDate);

    var output = "name: " + cookie.name() + ", value: " + cookie.value() + ", httpOnly: " + cookie.httpOnly() +
        ", secure: " + cookie.secure() + ", session: " + cookie.session() + ", path: " + cookie.path() +
        ", domain: " + cookie.domain() + ", port: " + cookie.port() +
        ", expires: " + (expires ? expires.getTime() : "n/a") +
        ", size: " + cookie.size();

    InspectorTest.addResult(output);
    InspectorTest.addObject(cookie.attributes());
}

InspectorTest.dumpCookies = function(cookies)
{
    for (var i = 0; i < cookies.length; ++i)
        InspectorTest.dumpCookie(cookies[i]);
}

InspectorTest.parseAndDumpCookie = function(header)
{
    var parser = new WebInspector.CookieParser();
    InspectorTest.addResult("source: " + header);
    InspectorTest.dumpCookies(parser.parseCookie(header));
}

InspectorTest.parseAndDumpSetCookie = function(header)
{
    var parser = new WebInspector.CookieParser();
    InspectorTest.addResult("source: " + header);
    InspectorTest.dumpCookies(parser.parseSetCookie(header));
}

}

var test = function()
{
    InspectorTest.parseAndDumpCookie("cookie=value");
    InspectorTest.parseAndDumpCookie("$version=1; a=b,c  =   d, e=f");
    InspectorTest.parseAndDumpCookie("$version=1; a=b;c  =   d; e =f");
    InspectorTest.parseAndDumpCookie("cooke1 = value1; another cookie = another value");
    InspectorTest.parseAndDumpCookie("cooke1 = value; $Path=/; $Domain=.example.com;");
    InspectorTest.parseAndDumpCookie("cooke1 = value; $Path=/; $Domain=.example.com ; Cookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com;");
    InspectorTest.parseAndDumpCookie("cooke1 = value; $Path=/; $Domain=.example.com\nCookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com; ");
    InspectorTest.parseAndDumpCookie("$version =1; cooke1 = value; $Path=/; $Domain   =.example.com;  \n Cookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com;");

    InspectorTest.parseAndDumpSetCookie("cookie=value");
    InspectorTest.parseAndDumpSetCookie("a=b\n c=d\n f");
    InspectorTest.parseAndDumpSetCookie("cooke1 = value; Path=/; Domain=.example.com;");
    InspectorTest.parseAndDumpSetCookie("cooke1 = value; Path=/; Domain=  .example.com \nCookie2 = value2; Path = /foo; Domain = foo.example.com");
    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;");
    InspectorTest.parseAndDumpSetCookie("cooke1 = value; max-age= 1440; Domain   =.example.com\n Cookie2 = value2; Path = /foo; DOMAIN = foo.example.com; HttpOnly; Secure; Discard;");
    InspectorTest.parseAndDumpSetCookie("cooke1; Path=/; Domain=.example.com;");
    InspectorTest.parseAndDumpSetCookie("cooke1=; Path=/; Domain=.example.com;");
    InspectorTest.completeTest();
}

</script>
</head>
<body onload="runTest()">
<p>Tests inspector cookie parser</p>
</body>
</html>