chromium/third_party/blink/web_tests/http/tests/websocket/zero-length-text.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("Test whether WebSocket handles zero length text frame correctly.");

window.jsTestIsAsync = true;

var ws = new WebSocket("ws://127.0.0.1:8880/zero-length-text");
var closeEvent;
var sequence = 0;
var receivedText = "";
var expectedText = "This first text should be received.This second text should be received, too.";

ws.onopen = function()
{
    debug("onopen() was called.");
};

ws.onmessage = function(event)
{
    var message = event.data;
    sequence++;
    if (sequence > 4) {
        testFailed("onmessage() was called. (message = \"" + message + "\")");
    } else {
        debug("onmessage() was called. (message = \"" + message + "\")");
        receivedText += message;
    }
};

ws.onclose = function(event)
{
    debug("onclose() was called.");
    closeEvent = event;
    shouldBeTrue("closeEvent.wasClean");
    shouldBe("sequence", "4");
    shouldBe("receivedText", "expectedText");
    finishJSTest();
};

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