JS Test Harness: Remove successfullyParsed from more tests
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / httponly-cookie.pl
1 #!/usr/bin/perl -wT
2 use strict;
3
4 if ($ENV{"QUERY_STRING"} eq "clear=1") {
5     print "Content-Type: text/plain\r\n";
6     print "Set-Cookie: WK-websocket-test=0; Max-Age=0\r\n";
7     print "Set-Cookie: WK-websocket-test-httponly=0; HttpOnly; Max-Age=0\r\n";
8     print "\r\n";
9     print "Cookies are cleared.";
10     exit;
11 }
12
13 print "Content-Type: text/html\r\n";
14 print "Set-Cookie: WK-websocket-test=1\r\n";
15 print "Set-Cookie: WK-websocket-test-httponly=1; HttpOnly\r\n";
16 print "\r\n";
17 print <<HTML
18 <html>
19 <head>
20 <script src="../../../../js-test-resources/js-test-pre.js"></script>
21 </head>
22 <body>
23 <p>Test WebSocket sends HttpOnly cookies.</p>
24 <p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
25 <div id="console"></div>
26 <script>
27 window.jsTestIsAsync = true;
28
29 var cookie;
30
31 // Normalize a cookie string
32 function normalizeCookie(cookie)
33 {
34     // Split the cookie string, sort it and then put it back together.
35     return cookie.split('; ').sort().join('; ');
36 }
37
38 function clearCookies()
39 {
40     var xhr = new XMLHttpRequest();
41     xhr.open("GET", "httponly-cookie.pl?clear=1", false);
42     xhr.send(null);
43 }
44
45 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hixie76/echo-cookie");
46 ws.onopen = function() {
47     debug("WebSocket open");
48 };
49 ws.onmessage = function(evt) {
50     cookie = evt.data;
51     ws.close();
52 };
53 ws.onclose = function() {
54     debug("WebSocket closed");
55     cookie = normalizeCookie(cookie);
56     shouldBe("cookie", '"WK-websocket-test-httponly=1; WK-websocket-test=1"');
57     clearCookies();
58     finishJSTest();
59 };
60
61 </script>
62 <script src="../../../../js-test-resources/js-test-post.js"></script>
63 </body>
64 </html>
65 HTML