const kUrl = "wss://example.com";
const data = "123456789ABCDEF";
let ws;
function testWebSocket() {
ws = new WebSocket(kUrl, "test");
ws.onopen = function() {
ok(true, "onopen is called");
ws.send(data);
};
ws.onmessage = function(e) {
if (e.data instanceof Blob) {
let reader = new FileReader();
reader.onload = function(event) {
is(data, event.target.result, "data should be the same");
ws.close();
};
reader.readAsText(e.data);
} else {
is(data, e.data, "data should be the same");
ws.close();
}
};
ws.onerror = function() {
ok(false, "onerror() should not have been called!");
SimpleTest.executeSoon(SimpleTest.finish);
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.