| OLD | NEW |
| 1 #!/usr/bin/perl -wT | 1 #!/usr/bin/perl -wT |
| 2 use strict; | 2 use strict; |
| 3 | 3 |
| 4 my $originPath = $ENV{"SCRIPT_NAME"}; | 4 my $originPath = $ENV{"SCRIPT_NAME"}; |
| 5 | 5 |
| 6 if ($ENV{"QUERY_STRING"} eq "clear=1") { | 6 if ($ENV{"QUERY_STRING"} eq "clear=1") { |
| 7 print "Content-Type: text/plain\r\n", | 7 print "Content-Type: text/plain\r\n", |
| 8 "Set-Cookie: WK-websocket-test-path=0; Path=$originPath; Max-Age=0\r\n
", | 8 "Set-Cookie: ws-path-origin-script=0; Path=$originPath; Max-Age=0\r\n"
, |
| 9 "Set-Cookie: WK-websocket-test-domain=0; Path=/; Domain=127.0.0.1; Max
-Age=0\r\n", | 9 "Set-Cookie: ws-path-root-domain-local-ip=0; Path=/; Domain=127.0.0.1;
Max-Age=0\r\n", |
| 10 "\r\n", | 10 "\r\n", |
| 11 "Cookies are cleared."; | 11 "Cookies are cleared."; |
| 12 exit; | 12 exit; |
| 13 } | 13 } |
| 14 | 14 |
| 15 print "Content-Type: text/html\r\n", | 15 print "Content-Type: text/html\r\n", |
| 16 # Test that even if the "Path" attribute of a cookie matches the path of the | 16 # Test that even if the "Path" attribute of a cookie matches the path of the |
| 17 # origin document, the cookie won't be sent in the WebSocket handshake unless | 17 # origin document, the cookie won't be sent in the WebSocket handshake unless |
| 18 # the "Path" attribute matches the WebSocket URL. | 18 # the "Path" attribute matches the WebSocket URL. |
| 19 "Set-Cookie: WK-websocket-test-path=1; Path=$originPath\r\n", | 19 "Set-Cookie: ws-path-origin-script=1; Path=$originPath\r\n", |
| 20 # Test that if the "Path" and "Domain" matches the WebSocket URL, the cookie | 20 # Test that if the "Path" and "Domain" matches the WebSocket URL, the cookie |
| 21 # will be sent in the WebSocket handshake. "Path" is set to / so that the | 21 # will be sent in the WebSocket handshake. "Path" is set to / so that the |
| 22 # WebSocket created below can pass "Path" check so that we can test that | 22 # WebSocket created below can pass "Path" check so that we can test that |
| 23 # "Domain" checking is working. | 23 # "Domain" checking is working. |
| 24 "Set-Cookie: WK-websocket-test-domain=1; Path=/; Domain=127.0.0.1\r\n", | 24 "Set-Cookie: ws-path-root-domain-local-ip=1; Path=/; Domain=127.0.0.1\r\n"
, |
| 25 "\r\n"; | 25 "\r\n"; |
| 26 print <<'HTML'; | 26 print <<'HTML'; |
| 27 <script src="/js-test-resources/js-test.js"></script> | 27 <script src="/js-test-resources/js-test.js"></script> |
| 28 <script src="resources/get-request-header.js"></script> | 28 <script src="resources/get-request-header.js"></script> |
| 29 <script> | 29 <script> |
| 30 description('Test how WebSocket handles cookies with cookie attributes.'); | 30 description('Test how WebSocket handles cookies with cookie attributes.'); |
| 31 | 31 |
| 32 window.jsTestIsAsync = true; | 32 window.jsTestIsAsync = true; |
| 33 | 33 |
| 34 // Normalize a cookie string | 34 // Normalize a cookie string |
| (...skipping 14 matching lines...) Expand all Loading... |
| 49 if (xhr.readyState == 4) { | 49 if (xhr.readyState == 4) { |
| 50 resolve(); | 50 resolve(); |
| 51 } | 51 } |
| 52 }; | 52 }; |
| 53 xhr.send(null); | 53 xhr.send(null); |
| 54 }); | 54 }); |
| 55 } | 55 } |
| 56 | 56 |
| 57 var cookie = normalizeCookie(document.cookie); | 57 var cookie = normalizeCookie(document.cookie); |
| 58 | 58 |
| 59 shouldBeEqualToString('cookie', 'WK-websocket-test-domain=1; WK-websocket-test-p
ath=1'); | 59 shouldBeEqualToString('cookie', 'ws-path-origin-script=1; ws-path-root-domain-lo
cal-ip=1'); |
| 60 | 60 |
| 61 connectAndGetRequestHeader('cookie').then(function(value) | 61 connectAndGetRequestHeader('cookie').then(function(value) |
| 62 { | 62 { |
| 63 cookie = value; | 63 cookie = value; |
| 64 shouldBeEqualToString('cookie', 'WK-websocket-test-domain=1'); | 64 shouldBeEqualToString('cookie', 'ws-path-root-domain-local-ip=1'); |
| 65 clearCookies().then(finishJSTest); | 65 clearCookies().then(finishJSTest); |
| 66 }, finishAsFailed); | 66 }, finishAsFailed); |
| 67 </script> | 67 </script> |
| 68 HTML | 68 HTML |
| OLD | NEW |