mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-27 02:20:17 +00:00
35 lines
No EOL
894 B
HTML
35 lines
No EOL
894 B
HTML
<script src="../include.js"></script>
|
|
<script>
|
|
asyncTest((done) => {
|
|
const ws = new WebSocket('wss://echo.websocket.org');
|
|
|
|
let messageCount = 0;
|
|
|
|
ws.onopen = function (ev) {
|
|
println(ev.type);
|
|
|
|
ws.onclose = function (ev) {
|
|
println(ev.type);
|
|
done();
|
|
}
|
|
ws.onerror = function (ev) {
|
|
println(ev.type);
|
|
done();
|
|
}
|
|
};
|
|
ws.onmessage = function (ev) {
|
|
if (ev.data.startsWith('WellHelloFriends')) {
|
|
println(`${ev.type} ${ev.data}`)
|
|
}
|
|
|
|
ws.send(`WellHelloFriends${messageCount}`);
|
|
if (messageCount++ === 5) {
|
|
ws.close();
|
|
}
|
|
}
|
|
ws.onerror = function (ev) {
|
|
println(ev.type);
|
|
done();
|
|
}
|
|
});
|
|
</script> |