2 <script src=
"/js-test-resources/js-test.js"></script>
3 <script src=
"resources/get-request-header.js"></script>
5 description('Test receiving cookies in a WebSocket handshake which were set by another WebSocket handshake.');
7 window
.jsTestIsAsync
= true;
9 // Normalize a cookie string
10 function normalizeCookie(cookie
) {
11 // Split the cookie string, sort it and then put it back together.
12 return cookie
.split('; ').sort().join('; ');
16 var URL_SET_COOKIE
= 'ws://127.0.0.1:8880/set-cookie';
17 var ws_set_cookie
= new WebSocket(URL_SET_COOKIE
);
19 ws_set_cookie
.onopen = function () {
20 ws_set_cookie
.close();
22 ws_set_cookie
.onclose = function (e
) {
23 connectAndGetRequestHeader('cookie').then(function(value
) {
24 cookie
= normalizeCookie(value
);
25 shouldBeEqualToString('cookie', 'WK-WebSocket-test-domain-pass=1; WK-WebSocket-test-path-pass=1; WK-WebSocket-test=1');
31 var ws
= new WebSocket(URL_SET_COOKIE
+ '?clear=1');
32 ws
.onopen = function () {
35 ws
.onclose
= finishJSTest
;
37 setTimeout(finishJSTest
, 1000);