From d0446de74a1d273e41a489e8f58f1b1f5c508036 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 24 Aug 2022 17:17:49 +0000 Subject: [PATCH 1/3] [wasm] Use explicity allowed ports with playwright, on linux too Fixes https://github.com/dotnet/runtime/issues/72436 . --- src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs index c39818f033d66b..e6d8a33eb6d2f2 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs @@ -77,12 +77,12 @@ public async Task RunAsync(ToolCommand cmd, string args, bool headless = var url = new Uri(urlAvailable.Task.Result); Playwright = await Microsoft.Playwright.Playwright.CreateAsync(); + string[] chromeArgs = new[] { $"--explicitly-allowed-ports={url.Port}" }; + Console.WriteLine($"Launching chrome ('{s_chromePath.Value}') via playwright with args = {string.Join(',', args)}"); Browser = await Playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions{ ExecutablePath = s_chromePath.Value, Headless = headless, - Args = OperatingSystem.IsWindows() - ? new[] { $"--explicitly-allowed-ports={url.Port}" } - : Array.Empty() + Args = chromeArgs }); IPage page = await Browser.NewPageAsync(); From 05af024eaee1a382de47ddf7da15eaca5029a347 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 24 Aug 2022 17:43:31 +0000 Subject: [PATCH 2/3] [wasm] Quote path, and arguments for wasm app host Fixes use of app host on windows, when it's installed in `c:\program files`. --- src/mono/wasm/build/WasmApp.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 2df2cf3dde077e..50f220060b0e03 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -126,7 +126,7 @@ $(DOTNET_HOST_PATH) dotnet - exec $([MSBuild]::NormalizePath($(WasmAppHostDir), 'WasmAppHost.dll')) --runtime-config $(_AppBundleDirForRunCommand)/$(AssemblyName).runtimeconfig.json $(WasmHostArguments) + exec "$([MSBuild]::NormalizePath($(WasmAppHostDir), 'WasmAppHost.dll'))" --runtime-config "$(_AppBundleDirForRunCommand)/$(AssemblyName).runtimeconfig.json" $(WasmHostArguments) $(_AppBundleDirForRunCommand) From 8d9bb1a59debc9ea564b140dafdf062c3d7bfb0b Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Wed, 24 Aug 2022 17:36:13 -0400 Subject: [PATCH 3/3] Update BrowserRunner.cs --- src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs index e6d8a33eb6d2f2..13a4ff96ab761a 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BrowserRunner.cs @@ -78,7 +78,7 @@ public async Task RunAsync(ToolCommand cmd, string args, bool headless = var url = new Uri(urlAvailable.Task.Result); Playwright = await Microsoft.Playwright.Playwright.CreateAsync(); string[] chromeArgs = new[] { $"--explicitly-allowed-ports={url.Port}" }; - Console.WriteLine($"Launching chrome ('{s_chromePath.Value}') via playwright with args = {string.Join(',', args)}"); + Console.WriteLine($"Launching chrome ('{s_chromePath.Value}') via playwright with args = {string.Join(',', chromeArgs)}"); Browser = await Playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions{ ExecutablePath = s_chromePath.Value, Headless = headless,