chromium/third_party/blink/web_tests/http/tests/websocket/bufferedAmount-after-send.html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<script type="text/javascript">
description('WebSocket bufferedAmount after send');

window.jsTestIsAsync = true;

var ws = new WebSocket('ws://localhost:8880/echo');

ws.onopen = function()
{
    debug('onopen');
    ws.send('hello');
    shouldBe('ws.bufferedAmount', '5');
    ws.send(new ArrayBuffer(32));
    shouldBe('ws.bufferedAmount', '37');
    ws.send(new Blob(['abc', 'de']));
    shouldBe('ws.bufferedAmount', '42');
    ws.send('bye');
    shouldBe('ws.bufferedAmount', '45');
    var id = setInterval(function() {
        if (ws.bufferedAmount === 0) {
            clearInterval(id);
            ws.close();
        }
    }, 50);
};

ws.onclose = function()
{
    debug('onclose');
    shouldBe('ws.bufferedAmount', '0');
    finishJSTest();
};

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