Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / cookie-resource-match.html
blob96e0f8df0e07e73e833bec61755eec99392ad8cb
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script>
6 function test() {
8 var cookies = [
9 createCookie("insecureOnlyWebkit", "1234567890", false, "webkit.org", "/"),
10 createCookie("insecureAllWebkit", "1234567890123456", false, ".webkit.org", "/"),
11 createCookie("insecureAllWebkitPath", "1234567890123456", false, ".webkit.org", "/path"),
12 createCookie("secureOnlyWebkitPath", "bar", true, "webkit.org", "/path"),
13 createCookie("secureAllWebkit", "foo", true, ".webkit.org", "/"),
14 createCookie("secureAllWebkitPath", "foo", true, ".webkit.org", "/path"),
15 createCookie("insecureOnlyWebkitPort", "1234567890", false, "webkit.org", "/", 80),
16 createCookie("insecureAllWebkitPort", "1234567890123456", false, ".webkit.org", "/", 80),
17 createCookie("insecureAllWebkitPathPort", "1234567890123456", false, ".webkit.org", "/path", 80),
18 createCookie("secureOnlyWebkitPathPort", "bar", true, "webkit.org", "/path", 80),
19 createCookie("secureAllWebkitPort", "foo", true, ".webkit.org", "/", 80),
20 createCookie("secureAllWebkitPathPort", "foo", true, ".webkit.org", "/path", 80),
21 createCookie("nonMatching1", "bar", false, "webkit.zoo", "/"),
22 createCookie("nonMatching2", "bar", false, "webkit.org", "/badPath"),
23 createCookie("nonMatching3", "bar", true, ".moo.com", "/")
26 var resourceURLs = [
27 "http://webkit.org", // 0
28 "http://www.webkit.org:81", // 1
29 "http://webkit.org/path", // 2
30 "http://www.webkit.org/path", // 3
31 "https://webkit.org/", // 4
32 "https://www.webkit.org/", // 5
33 "https://webkit.org:81/path", // 6
34 "https://www.webkit.org/path", // 7
36 "http://webkit.org:80", // 8
37 "http://www.webkit.org:80", // 9
38 "http://webkit.org:80/path", // 10
39 "http://www.webkit.org:80/path", // 11
40 "https://webkit.org:80/", // 12
41 "https://www.webkit.org:80/", // 13
42 "https://webkit.org:80/path", // 14
43 "https://www.webkit.org:80/path", // 15
45 "http://www.boo.com:80", // 16
46 "https://www.boo.com:80/path", // 17
47 "http://www.moo.com:80/", // 18
48 "http://www.boo.com:80", // 19
49 "https://www.boo.com:80/path", // 20
50 "http://www.moo.com:80/" // 21
53 var result = [];
54 for (var i = 0; i < cookies.length; ++i) {
55 var cookieResult = [];
56 for (var j = 0; j < resourceURLs.length; ++j) {
57 if (WebInspector.Cookies.cookieMatchesResourceURL(cookies[i], resourceURLs[j]))
58 cookieResult.push(j);
60 InspectorTest.addResult("[" + cookieResult + "]");
62 InspectorTest.completeTest();
64 function createCookie(name, value, secure, domain, path, port)
66 var protocolCookie = {
67 name: name,
68 value: value,
69 domain: domain,
70 port: port,
71 path: path,
72 expires: "Thu Jan 01 1970 00:00:00 GMT",
73 size: name.length + value.length,
74 httpOnly: false,
75 secure: secure,
76 firstPartyOnly: false,
77 session: true
79 return WebInspector.Cookies._parseProtocolCookie(WebInspector.targetManager.mainTarget(), protocolCookie);
82 </script>
83 </head>
85 <body onload="runTest()">
86 <p>
87 Tests that cookies are matched up with resources correctly.
88 </p>
90 </body>
91 </html>