Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: timelapse
Fetching contributors…

Cannot retrieve contributors at this time

74 lines (62 sloc) 3.284 kb
<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>
Jump to Line
Something went wrong with that request. Please try again.