<!DOCTYPE HTML><!-- webkit-test-runner [ dumpJSConsoleLogInStdErr=true ] -->
<html>
<head>
<script src="../../../../js-test-resources/js-test-pre.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/websocket/tests/hybi/handshake-fail-by-no-upgrade-header";
var ws = new WebSocket(url);

ws.onopen = function()
{
    debug("FAIL: Connected");
};

ws.onmessage = function(messageEvent)
{
    protocol = messageEvent.data;
    ws.close();
};

ws.onclose = function()
{
    endTest();
};

function timeOutCallback()
{
    debug("Timed out in state: " + ws.readyState);
    endTest();
}

var timeoutID = setTimeout(timeOutCallback, 3000);

</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
</body>
</html>
