From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- testing/xpcshell/node-ws/test/autobahn.js | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 testing/xpcshell/node-ws/test/autobahn.js (limited to 'testing/xpcshell/node-ws/test/autobahn.js') 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(); + } +}); -- cgit v1.2.3