summaryrefslogtreecommitdiffstats
path: root/testing/xpcshell/node-ws/test/websocket.integration.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/xpcshell/node-ws/test/websocket.integration.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/xpcshell/node-ws/test/websocket.integration.js55
1 files changed, 55 insertions, 0 deletions
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();
+ });
+ });
+});