From 0b6210cd37b68b94252cb798598b12974a20e1c1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 21 May 2024 22:56:19 +0200 Subject: Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3. Signed-off-by: Daniel Baumann --- .../resources/websockets-test-helpers.sub.js | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/wpt/tests/websockets/resources/websockets-test-helpers.sub.js (limited to 'test/wpt/tests/websockets/resources') diff --git a/test/wpt/tests/websockets/resources/websockets-test-helpers.sub.js b/test/wpt/tests/websockets/resources/websockets-test-helpers.sub.js new file mode 100644 index 0000000..2680670 --- /dev/null +++ b/test/wpt/tests/websockets/resources/websockets-test-helpers.sub.js @@ -0,0 +1,25 @@ +// The file including this must also include `/websockets/constants.sub.js to +// pick up the necessary constants. + +// Opens a new WebSocket connection. +async function openWebSocket(remoteContextHelper) { + let return_value = await remoteContextHelper.executeScript((domain) => { + return new Promise((resolve) => { + var webSocketInNotRestoredReasonsTests = new WebSocket(domain + '/echo'); + webSocketInNotRestoredReasonsTests.onopen = () => { resolve(42); }; + }); + }, [SCHEME_DOMAIN_PORT]); + assert_equals(return_value, 42); +} + +// Opens a new WebSocket connection and then close it. +async function openThenCloseWebSocket(remoteContextHelper) { + let return_value = await remoteContextHelper.executeScript((domain) => { + return new Promise((resolve) => { + var testWebSocket = new WebSocket(domain + '/echo'); + testWebSocket.onopen = () => { testWebSocket.close() }; + testWebSocket.onclose = () => { resolve(42) }; + }); + }, [SCHEME_DOMAIN_PORT]); + assert_equals(return_value, 42); +} -- cgit v1.2.3