blob: 70874fbfddfe2b9a066dba837743b75457271835 [file] [log] [blame]
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script>
function doit() {
function callback(result)
{
for (var i = 0; i < result.length; ++i)
output("[" + result[i] + "]");
notifyDone();
}
evaluateInWebInspector("frontend_doitAndDump", callback);
}
function frontend_doitAndDump()
{
var cookies = [
frontend_createCookie("insecureOnlyWebkit", "1234567890", false, "webkit.org", "/"),
frontend_createCookie("insecureAllWebkit", "1234567890123456", false, ".webkit.org", "/"),
frontend_createCookie("insecureAllWebkitPath", "1234567890123456", false, ".webkit.org", "/path"),
frontend_createCookie("secureOnlyWebkitPath", "bar", true, "webkit.org", "/path"),
frontend_createCookie("secureAllWebkit", "foo", true, ".webkit.org", "/"),
frontend_createCookie("secureAllWebkitPath", "foo", true, ".webkit.org", "/path"),
frontend_createCookie("insecureOnlyWebkitPort", "1234567890", false, "webkit.org", "/", 80),
frontend_createCookie("insecureAllWebkitPort", "1234567890123456", false, ".webkit.org", "/", 80),
frontend_createCookie("insecureAllWebkitPathPort", "1234567890123456", false, ".webkit.org", "/path", 80),
frontend_createCookie("secureOnlyWebkitPathPort", "bar", true, "webkit.org", "/path", 80),
frontend_createCookie("secureAllWebkitPort", "foo", true, ".webkit.org", "/", 80),
frontend_createCookie("secureAllWebkitPathPort", "foo", true, ".webkit.org", "/path", 80),
frontend_createCookie("nonMatching1", "bar", false, "webkit.zoo", "/"),
frontend_createCookie("nonMatching2", "bar", false, "webkit.org", "/badPath"),
frontend_createCookie("nonMatching3", "bar", true, ".moo.com", "/")
];
var resourceURLs = [
"http://webkit.org", // 0
"http://www.webkit.org:81", // 1
"http://webkit.org/path", // 2
"http://www.webkit.org/path", // 3
"https://webkit.org/", // 4
"https://www.webkit.org/", // 5
"https://webkit.org:81/path", // 6
"https://www.webkit.org/path", // 7
"http://webkit.org:80", // 8
"http://www.webkit.org:80", // 9
"http://webkit.org:80/path", // 10
"http://www.webkit.org:80/path", // 11
"https://webkit.org:80/", // 12
"https://www.webkit.org:80/", // 13
"https://webkit.org:80/path", // 14
"https://www.webkit.org:80/path", // 15
"http://www.boo.com:80", // 16
"https://www.boo.com:80/path", // 17
"http://www.moo.com:80/", // 18
"http://www.boo.com:80", // 19
"https://www.boo.com:80/path", // 20
"http://www.moo.com:80/" // 21
];
var result = [];
for (var i = 0; i < cookies.length; ++i) {
var cookieResult = [];
for (var j = 0; j < resourceURLs.length; ++j) {
if (WebInspector.Cookies.cookieMatchesResourceURL(cookies[i], resourceURLs[j]))
cookieResult.push(j);
}
result.push(cookieResult);
}
return result;
}
function frontend_createCookie(name, value, secure, domain, path, port)
{
return {
name: name,
value: value,
domain: domain,
port: port,
path: path,
expires: "Thu Jan 01 1970 00:00:00 GMT",
size: name.length + value.length,
httpOnly: false,
secure: secure,
session: true
};
}
</script>
</head>
<body onload="onload()">
<p>
Tests that cookies are matched up with resources correctly.
</p>
</body>
</html>