blob: 282391dad08af75f88aecb34d9ad95dc235986cb [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test that WebSocket handshake fails if Upgrade header field isn't reflected by the server.");
window.jsTestIsAsync = true;
function endTest()
{
clearTimeout(timeoutID);
finishJSTest();
}
var url = "ws://localhost:8880/handshake-fail-by-no-upgrade-header";
var ws = new WebSocket(url);
ws.onopen = function()
{
testFailed("Unexpectedly Connected.");
};
ws.onmessage = function(messageEvent)
{
protocol = messageEvent.data;
ws.close();
};
ws.onclose = function()
{
endTest();
};
ws.onerror = function(errorEvent)
{
testPassed("onerror() was called");
};
function timeOutCallback()
{
debug("Timed out in state: " + ws.readyState);
endTest();
}
var timeoutID = setTimeout(timeOutCallback, 3000);
</script>
</body>
</html>