chromium/third_party/blink/web_tests/http/tests/websocket/handshake-fail-by-404.html

<!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('Connection should fail immediately if the server returns a 404 error.');

window.jsTestIsAsync = true;

var url = 'ws://localhost:8880/handshake-fail-by-404';
var ws = new WebSocket(url);

var wasClean = null;

ws.onopen = function()
{
    testFailed('onopen called');
    ws.close();
}

ws.onclose = function(event)
{
    wasClean = event.wasClean;
    shouldBeFalse('wasClean');
    finishJSTest();
}

ws.onerror = function(errorEvent)
{
    testPassed("onerror() was called");
};

</script>
</body>
</html>