From 9e3c08db40b8916968b9f30096c7be3f00ce9647 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:44:51 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../xpcshell/node-ws/test/websocket.integration.js | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 testing/xpcshell/node-ws/test/websocket.integration.js (limited to 'testing/xpcshell/node-ws/test/websocket.integration.js') diff --git a/testing/xpcshell/node-ws/test/websocket.integration.js b/testing/xpcshell/node-ws/test/websocket.integration.js new file mode 100644 index 0000000000..abd96c61e4 --- /dev/null +++ b/testing/xpcshell/node-ws/test/websocket.integration.js @@ -0,0 +1,55 @@ +'use strict'; + +const assert = require('assert'); + +const WebSocket = require('..'); + +describe('WebSocket', () => { + it('communicates successfully with echo service (ws)', (done) => { + const ws = new WebSocket('ws://websocket-echo.com/', { + protocolVersion: 13 + }); + + let dataReceived = false; + + ws.on('open', () => { + ws.send('hello'); + }); + + ws.on('close', () => { + assert.ok(dataReceived); + done(); + }); + + ws.on('message', (message, isBinary) => { + dataReceived = true; + assert.ok(!isBinary); + assert.strictEqual(message.toString(), 'hello'); + ws.close(); + }); + }); + + it('communicates successfully with echo service (wss)', (done) => { + const ws = new WebSocket('wss://websocket-echo.com/', { + protocolVersion: 13 + }); + + let dataReceived = false; + + ws.on('open', () => { + ws.send('hello'); + }); + + ws.on('close', () => { + assert.ok(dataReceived); + done(); + }); + + ws.on('message', (message, isBinary) => { + dataReceived = true; + assert.ok(!isBinary); + assert.strictEqual(message.toString(), 'hello'); + ws.close(); + }); + }); +}); -- cgit v1.2.3