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";
9 print "Cookies are cleared.";
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";
20 <script src="../../../../js-test-resources/js-test-pre.js"></script>
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>
27 window.jsTestIsAsync = true;
28 if (window.layoutTestController)
29 layoutTestController.overridePreference("WebKitHixie76WebSocketProtocolEnabled", 0);
33 // Normalize a cookie string
34 function normalizeCookie(cookie)
36 // Split the cookie string, sort it and then put it back together.
37 return cookie.split('; ').sort().join('; ');
40 function clearCookies()
42 var xhr = new XMLHttpRequest();
43 xhr.open("GET", "httponly-cookie.pl?clear=1", false);
47 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/echo-cookie");
48 ws.onopen = function() {
49 debug("WebSocket open");
51 ws.onmessage = function(evt) {
55 ws.onclose = function() {
56 debug("WebSocket closed");
57 cookie = normalizeCookie(cookie);
58 shouldBe("cookie", '"WK-websocket-test-httponly=1; WK-websocket-test=1"');
64 <script src="../../../../js-test-resources/js-test-post.js"></script>