blob: 896b7908cd5dbba4ca8bd393e270058d9710f4eb [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>EventSource Loader Buffering</title>
<script>
window.onload = function () {
setTimeout(test_es, 500);
};
function test_es() {
var len = 0;
var count = 0;
var step = 1000;
var es = new EventSource("eventsource-loader-buffering.php");
es.onopen = function () {
log("got 'open' event");
log("waiting for the first " + step + " 'message' events");
};
es.onmessage = function (evt) {
len += evt.data.length;
if (++count % step)
return;
log("got " + count + " 'message' events (" + len + " characters)", 1);
if (len >= 1e9)
end();
};
es.onerror = function () {
log("got 'error' event");
end();
};
function end() {
if (es.readyState != es.CLOSED)
es.close();
log("ENDED");
};
}
function log(message, updateLast) {
if (!log.list)
log.list = document.getElementById("log");
var text = document.createTextNode(message);
if (updateLast)
log.list.lastChild.replaceChild(text, log.list.lastChild.firstChild);
else
log.list.appendChild(document.createElement("li")).appendChild(text);
}
</script>
</head>
<body>
<p>Manual test to verify that the EventSource loader does not buffer data (may result in memory growth with long lived connections). Monitor memory usage; it should be stable. This file has to be served from the same web server as the php script with the same name.</p>
<ul id="log" style="list-style-type: none"></ul>
</body>
</html>