Update web-platform-tests to revision 4d96cccabc2feacd48e1dab9afc22b8af2225572

This commit is contained in:
Ms2ger 2015-06-23 16:47:26 +02:00
parent 0d236288cc
commit c66c6af0ba
1067 changed files with 63768 additions and 10900 deletions

View file

@ -8,38 +8,25 @@
<body>
<div id="log"></div>
<script>
var test = async_test(null, {timeout: 5000});
var url = "resources/message.py?sleep=1000&message=" + encodeURIComponent("retry:1000\ndata:abc\n\n");
var es = new EventSource(url);
var lastEventTime = 0;
var lastEventType = "";
var readyStateAtLastEvent = -1;
es.onmessage =
es.onerror =
es.onopen = function (event) {
lastEventTime = (new Date()).getTime();
lastEventType = event.type;
readyStateAtLastEvent = es.readyState;
};
setTimeout(function () {
if (typeof window.stop === "function") {
window.stop();
}
}, 100);
setTimeout(function () {
test.step(function () {
var isActive = ((new Date()).getTime() - lastEventTime) < 2500;
if (es.readyState === EventSource.CLOSED) {
assert_true(!isActive, "In case EventSource was stopped, it should not be active");
assert_equals(lastEventType, "error", "In case EventSource was stopped, the last event should be an error event");
assert_equals(readyStateAtLastEvent, EventSource.CLOSED, "In case EventSource was stopped, readyState at last event should be closed");
} else {
assert_true(isActive, "EventSource is active, but readyState is not EventSource.CLOSED.");
}
var t = async_test();
onload = t.step_func(function() {
var url = "resources/message.py?sleep=1000&message=" + encodeURIComponent("retry:1000\ndata:abc\n\n");
var es = new EventSource(url);
es.onerror = t.step_func(function() {
assert_equals(es.readyState, EventSource.CLOSED)
setTimeout(t.step_func(function () {
assert_equals(es.readyState, EventSource.CLOSED,
"After stopping the eventsource readyState should be CLOSED")
t.done();
}), 1000);
});
es.close();
test.done();
}, 4000);
setTimeout(t.step_func(function() {
window.stop()
es.onopen = t.unreached_func("Got open event");
es.onmessage = t.unreached_func("Got message after closing source");
}), 0);
});
</script>
</body>
</html>