From 9c5215738cdb7e240c8520f87fe60c08653b0bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 5 Jan 2022 18:02:05 +0100 Subject: [PATCH 01/21] - NPM package with WS. --- .../System.Net.WebSockets.Client.Tests.csproj | 2 + .../tests/package-lock.json | 44 +++++++++++++++++++ .../tests/package.json | 14 ++++++ 3 files changed, 60 insertions(+) create mode 100644 src/libraries/System.Net.WebSockets.Client/tests/package-lock.json create mode 100644 src/libraries/System.Net.WebSockets.Client/tests/package.json diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 956ee4d4146122..15c84dfb41f78e 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -16,6 +16,8 @@ + + =10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + }, + "dependencies": { + "ws": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.0.tgz", + "integrity": "sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==", + "requires": {} + } + } +} diff --git a/src/libraries/System.Net.WebSockets.Client/tests/package.json b/src/libraries/System.Net.WebSockets.Client/tests/package.json new file mode 100644 index 00000000000000..4d77460973d533 --- /dev/null +++ b/src/libraries/System.Net.WebSockets.Client/tests/package.json @@ -0,0 +1,14 @@ +{ + "name": "system.net.websockets.client.tests", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "ws": "^8.4.0" + } +} From ff1304d176ce7383703493adade3cf2179853874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 5 Jan 2022 18:02:58 +0100 Subject: [PATCH 02/21] - Restore npm. --- eng/testing/WasmRunnerTemplate.cmd | 7 ++++++- .../Wasm.Build.Tests/data/RunScriptTemplate.cmd | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/eng/testing/WasmRunnerTemplate.cmd b/eng/testing/WasmRunnerTemplate.cmd index a668ce2c6a464c..9a99a4c25a4cde 100644 --- a/eng/testing/WasmRunnerTemplate.cmd +++ b/eng/testing/WasmRunnerTemplate.cmd @@ -1,4 +1,4 @@ -@echo off +@REM @echo off setlocal enabledelayedexpansion :: SetCommands defined in eng\testing\tests.wasm.targets @@ -6,6 +6,11 @@ setlocal enabledelayedexpansion [[SetCommandsEcho]] set EXECUTION_DIR=%~dp0 + +if exist "package.json" ( + cmd /c "cd %EXECUTION_DIR% && npm ci" +) + if [%3] NEQ [] ( set SCENARIO=%3 ) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd index 56c194e21e8a1c..8e2352710ed74b 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd @@ -6,6 +6,11 @@ setlocal enabledelayedexpansion [[SetCommandsEcho]] set EXECUTION_DIR=%~dp0 + +if exist "package.json" ( + cmd /c "cd %EXECUTION_DIR% && npm ci" +) + if [%3] NEQ [] ( set SCENARIO=%3 ) From 67a84c43047ca4b9eb583809552fdfc8b06b0ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 5 Jan 2022 18:03:27 +0100 Subject: [PATCH 03/21] - Load npm modules in tests. --- .../System.Net.WebSockets.Client.Tests.csproj | 1 + src/mono/wasm/test-main.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 15c84dfb41f78e..ce611be9be94fd 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -10,6 +10,7 @@ $(TestArchiveRoot)browseronly/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ $(DefineConstants);TARGET_BROWSER + --setenv=NPM_MODULES=ws:WebSocket diff --git a/src/mono/wasm/test-main.js b/src/mono/wasm/test-main.js index 4348444be62995..ac2b9a1c510186 100644 --- a/src/mono/wasm/test-main.js +++ b/src/mono/wasm/test-main.js @@ -354,6 +354,24 @@ try { console.error(e); } +if (is_node) { + const modulesToLoad = processedArguments.setenv["NPM_MODULES"]; + if (modulesToLoad) { + modulesToLoad.split(',').forEach(module => { + const parts = module.split(':'); + + let message = `Loading npm '${parts[0]}'`; + const moduleExport = require(parts[0]); + if (parts.length == 2) { + message += ` attaching to global as '${parts[1]}'.`; + globalThis[parts[1]] = moduleExport; + } + + console.log(message); + }); + } +} + async function loadDotnet(file) { let loadScript = undefined; if (typeof WScript !== "undefined") { // Chakra From a244b3fd6b00bcb8eb16c8f3a4717a0d098ae947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 6 Jan 2022 09:39:38 +0100 Subject: [PATCH 04/21] - NPM only on NodeJS. --- .../tests/System.Net.WebSockets.Client.Tests.csproj | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index ce611be9be94fd..57643e6800d587 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -10,15 +10,20 @@ $(TestArchiveRoot)browseronly/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ $(DefineConstants);TARGET_BROWSER - --setenv=NPM_MODULES=ws:WebSocket - - + + --setenv=NPM_MODULES=ws:WebSocket + + + + + + Date: Thu, 6 Jan 2022 09:51:37 +0100 Subject: [PATCH 05/21] - Use correct path for npm restore test. --- eng/testing/WasmRunnerTemplate.cmd | 2 +- .../BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/testing/WasmRunnerTemplate.cmd b/eng/testing/WasmRunnerTemplate.cmd index 9a99a4c25a4cde..9ad3de755535ca 100644 --- a/eng/testing/WasmRunnerTemplate.cmd +++ b/eng/testing/WasmRunnerTemplate.cmd @@ -7,7 +7,7 @@ setlocal enabledelayedexpansion set EXECUTION_DIR=%~dp0 -if exist "package.json" ( +if exist "%EXECUTION_DIR%\package-lock.json" ( cmd /c "cd %EXECUTION_DIR% && npm ci" ) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd index 8e2352710ed74b..beb6297d82340e 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd @@ -7,7 +7,7 @@ setlocal enabledelayedexpansion set EXECUTION_DIR=%~dp0 -if exist "package.json" ( +if exist "%EXECUTION_DIR%\package-lock.json" ( cmd /c "cd %EXECUTION_DIR% && npm ci" ) From 005298e0db2c1d3e419f68352a52a99b0990a080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 6 Jan 2022 09:54:43 +0100 Subject: [PATCH 06/21] - Update npm load message. --- src/mono/wasm/test-main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/test-main.js b/src/mono/wasm/test-main.js index ac2b9a1c510186..375186c017cb5f 100644 --- a/src/mono/wasm/test-main.js +++ b/src/mono/wasm/test-main.js @@ -363,7 +363,7 @@ if (is_node) { let message = `Loading npm '${parts[0]}'`; const moduleExport = require(parts[0]); if (parts.length == 2) { - message += ` attaching to global as '${parts[1]}'.`; + message += ` and attaching to global as '${parts[1]}'.`; globalThis[parts[1]] = moduleExport; } From 208c826c2fc5f51bd4648b49f12790fc24a7d192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 7 Jan 2022 09:50:40 +0100 Subject: [PATCH 07/21] - Enable WebSocket tests on NodeJS. --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 1 + .../System.Net.WebSockets.Client/tests/WebSocketHelper.cs | 2 +- src/mono/wasm/test-main.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index bdab9c979cc499..294c4bd0089079 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -72,6 +72,7 @@ public static partial class PlatformDetection public static bool IsBrowserDomSupported => GetIsBrowserDomSupported(); public static bool IsBrowserDomSupportedOrNotBrowser => IsNotBrowser || GetIsBrowserDomSupported(); public static bool IsNotBrowserDomSupported => !IsBrowserDomSupported; + public static string Host => Environment.GetEnvironmentVariable("Host"); public static bool LocalEchoServerIsNotAvailable => !LocalEchoServerIsAvailable; public static bool LocalEchoServerIsAvailable => IsBrowser; diff --git a/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs b/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs index 1f0ccd55913214..56d5e23b89d3c3 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs @@ -125,7 +125,7 @@ public static async Task Retry(ITestOutputHelper output, Func> fun private static bool InitWebSocketSupported() { ClientWebSocket cws = null; - if (PlatformDetection.IsBrowser && !PlatformDetection.IsBrowserDomSupported) + if (PlatformDetection.IsBrowser && PlatformDetection.Host == "v8") { return false; } diff --git a/src/mono/wasm/test-main.js b/src/mono/wasm/test-main.js index 375186c017cb5f..2de9ae10fa1649 100644 --- a/src/mono/wasm/test-main.js +++ b/src/mono/wasm/test-main.js @@ -314,6 +314,7 @@ function processArguments(incomingArguments) { // cheap way to let the testing infrastructure know we're running in a browser context (or not) setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); + setenv["Host"] = is_browser ? "browser" : is_node ? "nodejs" : "v8"; console.log("Application arguments: " + incomingArguments.join(' ')); From d8afe4c24699807a6ac6916b1f4e3105d762a4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 7 Jan 2022 09:51:01 +0100 Subject: [PATCH 08/21] - Set NODE_TLS_REJECT_UNAUTHORIZED=0 to enable self-signed certs on NodeJS. --- .../tests/System.Net.WebSockets.Client.Tests.csproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 57643e6800d587..4350958c988d4c 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -21,6 +21,12 @@ + + + + + + From 9786319a1524dd6a7aa1bb12aafb1fc6abab8a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 11 Jan 2022 11:27:56 +0100 Subject: [PATCH 09/21] - Disable not working tests. --- src/libraries/System.Net.WebSockets.Client/tests/AbortTest.cs | 1 + .../System.Net.WebSockets.Client/tests/ConnectTest.cs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/AbortTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/AbortTest.cs index 209a6f10ff23b4..44551c4d242cce 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/AbortTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/AbortTest.cs @@ -17,6 +17,7 @@ public AbortTest(ITestOutputHelper output) : base(output) { } [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] + [ActiveIssue("TBD", TestPlatforms.Browser)] public async Task Abort_ConnectAndAbort_ThrowsWebSocketExceptionWithmessage(Uri server) { using (var cws = new ClientWebSocket()) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs index 31c375a9cd499a..4906e139f82415 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs @@ -170,6 +170,7 @@ public async Task ConnectAsync_CookieHeaders_Success(Uri server) [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] + [ActiveIssue("TBD", TestPlatforms.Browser)] public async Task ConnectAsync_PassNoSubProtocol_ServerRequires_ThrowsWebSocketException(Uri server) { const string AcceptedProtocol = "CustomProtocol"; @@ -256,6 +257,7 @@ public async Task ConnectAndCloseAsync_UseProxyServer_ExpectedClosedState(Uri se } [ConditionalFact(nameof(WebSocketsSupported))] + [ActiveIssue("TBD", TestPlatforms.Browser)] public async Task ConnectAsync_CancellationRequestedBeforeConnect_ThrowsOperationCanceledException() { using (var clientSocket = new ClientWebSocket()) @@ -268,6 +270,7 @@ public async Task ConnectAsync_CancellationRequestedBeforeConnect_ThrowsOperatio } [ConditionalFact(nameof(WebSocketsSupported))] + // [ActiveIssue("TBD", TestPlatforms.Browser)] public async Task ConnectAsync_CancellationRequestedInflightConnect_ThrowsOperationCanceledException() { using (var clientSocket = new ClientWebSocket()) @@ -281,6 +284,7 @@ public async Task ConnectAsync_CancellationRequestedInflightConnect_ThrowsOperat [ConditionalFact(nameof(WebSocketsSupported))] [ActiveIssue("https://github.com/dotnet/runtime/issues/34690", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] + [ActiveIssue("TBD", TestPlatforms.Browser)] public async Task ConnectAsync_CancellationRequestedAfterConnect_ThrowsOperationCanceledException() { var releaseServer = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); From ac307e6f2e35fca7acd942a38719dcb192e39db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 11 Jan 2022 11:43:45 +0100 Subject: [PATCH 10/21] - Feedback. --- eng/testing/WasmRunnerTemplate.cmd | 7 +------ .../System.Net.WebSockets.Client/tests/ConnectTest.cs | 2 +- .../tests/System.Net.WebSockets.Client.Tests.csproj | 9 +++++++-- .../tests/WebSocketHelper.cs | 2 +- .../Wasm.Build.Tests/data/RunScriptTemplate.cmd | 5 ----- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/eng/testing/WasmRunnerTemplate.cmd b/eng/testing/WasmRunnerTemplate.cmd index 9ad3de755535ca..a668ce2c6a464c 100644 --- a/eng/testing/WasmRunnerTemplate.cmd +++ b/eng/testing/WasmRunnerTemplate.cmd @@ -1,4 +1,4 @@ -@REM @echo off +@echo off setlocal enabledelayedexpansion :: SetCommands defined in eng\testing\tests.wasm.targets @@ -6,11 +6,6 @@ setlocal enabledelayedexpansion [[SetCommandsEcho]] set EXECUTION_DIR=%~dp0 - -if exist "%EXECUTION_DIR%\package-lock.json" ( - cmd /c "cd %EXECUTION_DIR% && npm ci" -) - if [%3] NEQ [] ( set SCENARIO=%3 ) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs index 4906e139f82415..9e9a4d767aacca 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs @@ -270,7 +270,7 @@ public async Task ConnectAsync_CancellationRequestedBeforeConnect_ThrowsOperatio } [ConditionalFact(nameof(WebSocketsSupported))] - // [ActiveIssue("TBD", TestPlatforms.Browser)] + [ActiveIssue("TBD", TestPlatforms.Browser)] public async Task ConnectAsync_CancellationRequestedInflightConnect_ThrowsOperationCanceledException() { using (var clientSocket = new ClientWebSocket()) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 4350958c988d4c..ee0f5f02684a3e 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -21,11 +21,16 @@ + - + + - + + + + diff --git a/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs b/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs index 56d5e23b89d3c3..a02ff2d4a4c888 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs @@ -125,7 +125,7 @@ public static async Task Retry(ITestOutputHelper output, Func> fun private static bool InitWebSocketSupported() { ClientWebSocket cws = null; - if (PlatformDetection.IsBrowser && PlatformDetection.Host == "v8") + if (PlatformDetection.IsBrowser && (PlatformDetection.Host == "v8" || PlatformDetection.Host == "SpiderMonkey")) { return false; } diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd index beb6297d82340e..56c194e21e8a1c 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.cmd @@ -6,11 +6,6 @@ setlocal enabledelayedexpansion [[SetCommandsEcho]] set EXECUTION_DIR=%~dp0 - -if exist "%EXECUTION_DIR%\package-lock.json" ( - cmd /c "cd %EXECUTION_DIR% && npm ci" -) - if [%3] NEQ [] ( set SCENARIO=%3 ) From b6cd7cfad355ee0aa11112653b29e71429d70340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 11 Jan 2022 11:47:24 +0100 Subject: [PATCH 11/21] - Restore NPM on linux. --- .../tests/System.Net.WebSockets.Client.Tests.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index ee0f5f02684a3e..9cc73dc916665d 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -25,6 +25,8 @@ + + From 31f0cd88276271e0c0ec7246e007dda56c419a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Tue, 11 Jan 2022 11:55:45 +0100 Subject: [PATCH 12/21] - Use pushd and popd on linux. --- .../tests/System.Net.WebSockets.Client.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 9cc73dc916665d..8b9cec2c534e0d 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -26,7 +26,7 @@ - + From 131ba8f4bb88aa109e134c78d411c280ad0c7521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 12 Jan 2022 09:55:22 +0100 Subject: [PATCH 13/21] - Fill issue links to ActiveIssue placeholders. --- .../System.Net.WebSockets.Client/tests/AbortTest.cs | 2 +- .../System.Net.WebSockets.Client/tests/ConnectTest.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/AbortTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/AbortTest.cs index 44551c4d242cce..a5d97a9a421885 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/AbortTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/AbortTest.cs @@ -17,7 +17,7 @@ public AbortTest(ITestOutputHelper output) : base(output) { } [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] - [ActiveIssue("TBD", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/63673", TestPlatforms.Browser)] public async Task Abort_ConnectAndAbort_ThrowsWebSocketExceptionWithmessage(Uri server) { using (var cws = new ClientWebSocket()) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs index 9e9a4d767aacca..ae56fe781f30a4 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs @@ -257,7 +257,7 @@ public async Task ConnectAndCloseAsync_UseProxyServer_ExpectedClosedState(Uri se } [ConditionalFact(nameof(WebSocketsSupported))] - [ActiveIssue("TBD", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/63672", TestPlatforms.Browser)] public async Task ConnectAsync_CancellationRequestedBeforeConnect_ThrowsOperationCanceledException() { using (var clientSocket = new ClientWebSocket()) @@ -270,7 +270,7 @@ public async Task ConnectAsync_CancellationRequestedBeforeConnect_ThrowsOperatio } [ConditionalFact(nameof(WebSocketsSupported))] - [ActiveIssue("TBD", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/63672", TestPlatforms.Browser)] public async Task ConnectAsync_CancellationRequestedInflightConnect_ThrowsOperationCanceledException() { using (var clientSocket = new ClientWebSocket()) @@ -284,7 +284,7 @@ public async Task ConnectAsync_CancellationRequestedInflightConnect_ThrowsOperat [ConditionalFact(nameof(WebSocketsSupported))] [ActiveIssue("https://github.com/dotnet/runtime/issues/34690", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] - [ActiveIssue("TBD", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/63671", TestPlatforms.Browser)] public async Task ConnectAsync_CancellationRequestedAfterConnect_ThrowsOperationCanceledException() { var releaseServer = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); From 1f39490f2daccaf9c98d436dc4ad420c8e57a253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 12 Jan 2022 11:02:52 +0100 Subject: [PATCH 14/21] - Replace "host" env variable with specific "IsWebSocketSupported". --- .../tests/TestUtilities/System/PlatformDetection.cs | 10 +++++----- .../tests/WebSocketHelper.cs | 2 +- src/mono/wasm/test-main.js | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 294c4bd0089079..e1d416765a9d49 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -69,10 +69,10 @@ public static partial class PlatformDetection public static bool IsSpeedOptimized => !IsSizeOptimized; public static bool IsSizeOptimized => IsBrowser || IsAndroid || IsAppleMobile; - public static bool IsBrowserDomSupported => GetIsBrowserDomSupported(); - public static bool IsBrowserDomSupportedOrNotBrowser => IsNotBrowser || GetIsBrowserDomSupported(); + public static bool IsBrowserDomSupported => IsEnvironmentVariableTrue("IsBrowserDomSupported"); + public static bool IsBrowserDomSupportedOrNotBrowser => IsNotBrowser || IsBrowserDomSupported; public static bool IsNotBrowserDomSupported => !IsBrowserDomSupported; - public static string Host => Environment.GetEnvironmentVariable("Host"); + public static bool IsWebSocketSupported => IsEnvironmentVariableTrue("IsWebSocketSupported"); public static bool LocalEchoServerIsNotAvailable => !LocalEchoServerIsAvailable; public static bool LocalEchoServerIsAvailable => IsBrowser; @@ -495,12 +495,12 @@ private static bool GetIsRunningOnMonoInterpreter() #endif } - private static bool GetIsBrowserDomSupported() + private static bool IsEnvironmentVariableTrue(string variableName) { if (!IsBrowser) return false; - var val = Environment.GetEnvironmentVariable("IsBrowserDomSupported"); + var val = Environment.GetEnvironmentVariable(variableName); return (val != null && val == "true"); } } diff --git a/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs b/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs index a02ff2d4a4c888..0782f9d5232e42 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/WebSocketHelper.cs @@ -125,7 +125,7 @@ public static async Task Retry(ITestOutputHelper output, Func> fun private static bool InitWebSocketSupported() { ClientWebSocket cws = null; - if (PlatformDetection.IsBrowser && (PlatformDetection.Host == "v8" || PlatformDetection.Host == "SpiderMonkey")) + if (PlatformDetection.IsBrowser && !PlatformDetection.IsWebSocketSupported) { return false; } diff --git a/src/mono/wasm/test-main.js b/src/mono/wasm/test-main.js index 2de9ae10fa1649..9de96a2749fcc2 100644 --- a/src/mono/wasm/test-main.js +++ b/src/mono/wasm/test-main.js @@ -314,7 +314,6 @@ function processArguments(incomingArguments) { // cheap way to let the testing infrastructure know we're running in a browser context (or not) setenv["IsBrowserDomSupported"] = is_browser.toString().toLowerCase(); - setenv["Host"] = is_browser ? "browser" : is_node ? "nodejs" : "v8"; console.log("Application arguments: " + incomingArguments.join(' ')); @@ -373,6 +372,9 @@ if (is_node) { } } +// Must be after loading npm modules. +processedArguments.setenv["IsWebSocketSupported"] = ("WebSocket" in globalThis).toString().toLowerCase(); + async function loadDotnet(file) { let loadScript = undefined; if (typeof WScript !== "undefined") { // Chakra From 323dd9905ff07492a33fe14634107a55bdae658f Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 12 Jan 2022 13:04:31 +0100 Subject: [PATCH 15/21] Update package.json --- .../System.Net.WebSockets.Client/tests/package.json | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/package.json b/src/libraries/System.Net.WebSockets.Client/tests/package.json index 4d77460973d533..cb5a738db17e5a 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/package.json +++ b/src/libraries/System.Net.WebSockets.Client/tests/package.json @@ -1,14 +1,7 @@ { "name": "system.net.websockets.client.tests", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", + "private": true, "dependencies": { - "ws": "^8.4.0" + "ws": "8.4.0" } } From e02e7d156e0a3579832a8332803e1a89a48d8830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 12 Jan 2022 13:46:57 +0100 Subject: [PATCH 16/21] - Fill issue links to ActiveIssue placeholders. --- src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs index ae56fe781f30a4..75b378f5056362 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs @@ -170,7 +170,7 @@ public async Task ConnectAsync_CookieHeaders_Success(Uri server) [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] - [ActiveIssue("TBD", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/63681", TestPlatforms.Browser)] public async Task ConnectAsync_PassNoSubProtocol_ServerRequires_ThrowsWebSocketException(Uri server) { const string AcceptedProtocol = "CustomProtocol"; From 155a424c0b1ff38e70a6f3a30479881ca30daf23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Thu, 13 Jan 2022 13:31:29 +0100 Subject: [PATCH 17/21] Run on CI? --- .../tests/System.Net.WebSockets.Client.Tests.csproj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 8b9cec2c534e0d..583beaf84ec148 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -6,8 +6,9 @@ + WasmTestOnBrowser - $(TestArchiveRoot)browseronly/ + $(TestArchiveRoot)browserornodejs/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ $(DefineConstants);TARGET_BROWSER @@ -25,14 +26,18 @@ + + + + From d21982b2281f2c0a86535aa9358b707c39e9f7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 14 Jan 2022 11:14:40 +0100 Subject: [PATCH 18/21] Run on CI?? --- eng/testing/tests.wasm.targets | 4 ++-- .../System.Net.WebSockets.Client.Tests.csproj | 23 ++++++++----------- .../WebAssembly.Browser.HotReload.Test.csproj | 3 +++ ...Assembly.Browser.RuntimeConfig.Test.csproj | 3 +++ 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index 191d2c2295690f..bed571a3064021 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -29,13 +29,13 @@ See also eng\testing\WasmRunnerTemplate.sh --> - + - + diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 583beaf84ec148..15dc3955d803d0 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -15,29 +15,24 @@ - - --setenv=NPM_MODULES=ws:WebSocket - - + - + - - + + - - + - + - - + + - - + diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/WebAssembly.Browser.HotReload.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/WebAssembly.Browser.HotReload.Test.csproj index f3ca0161fc5fe6..7e2602501266f1 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/WebAssembly.Browser.HotReload.Test.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/WebAssembly.Browser.HotReload.Test.csproj @@ -5,6 +5,9 @@ false true WasmTestOnBrowser + $(TestArchiveRoot)browseronly/ + $(TestArchiveTestsRoot)$(OSPlatformConfig)/ + $(DefineConstants);TARGET_BROWSER 42 main.js false diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj index d9c7984051cd39..90d9fa155b9245 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj @@ -2,6 +2,9 @@ true WasmTestOnBrowser + $(TestArchiveRoot)browseronly/ + $(TestArchiveTestsRoot)$(OSPlatformConfig)/ + $(DefineConstants);TARGET_BROWSER 42 main.js From 8161df10386005d4262fdf3df520c15afc7bf41c Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 14 Jan 2022 13:58:45 +0100 Subject: [PATCH 19/21] fix --- .../tests/System/Net/Prerequisites/LocalEchoServer.props | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props b/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props index f70812e39b6855..3df500bdb8e3ea 100644 --- a/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props +++ b/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props @@ -1,9 +1,5 @@ - WasmTestOnBrowser - $(TestArchiveRoot)browseronly/ - $(TestArchiveTestsRoot)$(OSPlatformConfig)/ - <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OS)' == 'Windows_NT'">%HELIX_CORRELATION_PAYLOAD%/xharness/TestEchoMiddleware <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OS)' != 'Windows_NT'">$HELIX_CORRELATION_PAYLOAD/xharness/TestEchoMiddleware From 292882a326c879936a7601c3780e95430bea0b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 14 Jan 2022 16:40:08 +0100 Subject: [PATCH 20/21] Use WASM_XHARNESS_MONO_ARGS var in runner templates. --- eng/testing/WasmRunnerTemplate.cmd | 2 +- eng/testing/WasmRunnerTemplate.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/testing/WasmRunnerTemplate.cmd b/eng/testing/WasmRunnerTemplate.cmd index a668ce2c6a464c..2ebcbcf8e93a97 100644 --- a/eng/testing/WasmRunnerTemplate.cmd +++ b/eng/testing/WasmRunnerTemplate.cmd @@ -54,7 +54,7 @@ if /I [%XHARNESS_COMMAND%] == [test] ( ) if [%XHARNESS_ARGS%] == [] ( - set "XHARNESS_ARGS=%JS_ENGINE% %JS_ENGINE_ARGS% %BROWSER_PATH% %MAIN_JS%" + set "XHARNESS_ARGS=%JS_ENGINE% %JS_ENGINE_ARGS% %BROWSER_PATH% %MAIN_JS% %WASM_XHARNESS_MONO_ARGS%" ) echo EXECUTION_DIR=%EXECUTION_DIR% diff --git a/eng/testing/WasmRunnerTemplate.sh b/eng/testing/WasmRunnerTemplate.sh index ae78d5304e8aed..d4e352976e8075 100644 --- a/eng/testing/WasmRunnerTemplate.sh +++ b/eng/testing/WasmRunnerTemplate.sh @@ -50,7 +50,7 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then fi if [[ -z "$XHARNESS_ARGS" ]]; then - XHARNESS_ARGS="$JS_ENGINE $JS_ENGINE_ARGS $MAIN_JS" + XHARNESS_ARGS="$JS_ENGINE $JS_ENGINE_ARGS $MAIN_JS $WASM_XHARNESS_MONO_ARGS" fi echo EXECUTION_DIR=$EXECUTION_DIR From 7677b01606406147b2b83448964b7b9353c5e98a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Mon, 17 Jan 2022 10:21:49 +0100 Subject: [PATCH 21/21] Use call in npm ci script on Windows. --- .../tests/System.Net.WebSockets.Client.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 15dc3955d803d0..c553a385144b32 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -32,7 +32,7 @@ - +