4 <script src=
"/js-test-resources/js-test.js"></script>
7 <div id=
"description"></div>
8 <div id=
"console"></div>
10 description("Test that WebSocket handshake fails if there are more than one Sec-WebSocket-Protocol header field in the response.");
12 window
.jsTestIsAsync
= true;
16 clearTimeout(timeoutID
);
20 var url
= "ws://localhost:8880/handshake-fail-by-more-protocol-header";
21 var ws
= new WebSocket(url
, "MatchProtocol");
23 ws
.onopen = function()
25 testFailed("Unexpectedly Connected.");
28 ws
.onmessage = function(messageEvent
)
30 testFailed("Unexpectedly Received: '" + messageEvent
.data
+ "'");
33 ws
.onclose = function()
38 ws
.onerror = function(errorEvent
)
40 testPassed("onerror() was called");
43 function timeOutCallback()
45 debug("Timed out in state: " + ws
.readyState
);
49 var timeoutID
= setTimeout(timeOutCallback
, 3000);