summaryrefslogtreecommitdiffstats
path: root/testing/xpcshell/node-ws/test/autobahn.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/xpcshell/node-ws/test/autobahn.js
parentInitial commit. (diff)
downloadthunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz
thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/xpcshell/node-ws/test/autobahn.js')
-rw-r--r--testing/xpcshell/node-ws/test/autobahn.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/xpcshell/node-ws/test/autobahn.js b/testing/xpcshell/node-ws/test/autobahn.js
new file mode 100644
index 0000000000..51532fc52e
--- /dev/null
+++ b/testing/xpcshell/node-ws/test/autobahn.js
@@ -0,0 +1,39 @@
+'use strict';
+
+const WebSocket = require('../');
+
+let currentTest = 1;
+let testCount;
+
+function nextTest() {
+ let ws;
+
+ if (currentTest > testCount) {
+ ws = new WebSocket('ws://localhost:9001/updateReports?agent=ws');
+ return;
+ }
+
+ console.log(`Running test case ${currentTest}/${testCount}`);
+
+ ws = new WebSocket(
+ `ws://localhost:9001/runCase?case=${currentTest}&agent=ws`
+ );
+ ws.on('message', (data, isBinary) => {
+ ws.send(data, { binary: isBinary });
+ });
+ ws.on('close', () => {
+ currentTest++;
+ process.nextTick(nextTest);
+ });
+ ws.on('error', (e) => console.error(e));
+}
+
+const ws = new WebSocket('ws://localhost:9001/getCaseCount');
+ws.on('message', (data) => {
+ testCount = parseInt(data);
+});
+ws.on('close', () => {
+ if (testCount > 0) {
+ nextTest();
+ }
+});