diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets
index e4bb68a868165..e726afa666143 100644
--- a/eng/testing/tests.wasm.targets
+++ b/eng/testing/tests.wasm.targets
@@ -36,6 +36,7 @@
('$(ContinuousIntegrationBuild)' != 'true' or Exists('/.dockerenv')) and
'$(Scenario)' == 'WasmTestOnBrowser'">true
<_XHarnessTestsTimeout>00:30:00
+ $(BundleDir)
- --runtime-config $(BundleDir)/WasmTestRunner.runtimeconfig.json $(WasmHostArguments) $(StartArguments) $(WasmXHarnessMonoArgs) $(_AppArgs)
+ <_RuntimeConfigJsonPath>$([MSBuild]::NormalizePath($(BundleDir), 'WasmTestRunner.runtimeconfig.json'))
+ exec "$([MSBuild]::NormalizePath($(WasmAppHostDir), 'WasmAppHost.dll'))" --runtime-config "$(_RuntimeConfigJsonPath)" $(WasmHostArguments) $(StartArguments) $(WasmXHarnessMonoArgs) $(_AppArgs)
diff --git a/src/mono/wasm/test-main.js b/src/mono/wasm/test-main.js
index 8f37accb9a4bc..979c8a2d90ae0 100644
--- a/src/mono/wasm/test-main.js
+++ b/src/mono/wasm/test-main.js
@@ -10,7 +10,7 @@
/*****************************************************************************
* Please don't use this as template for startup code.
* There are simpler and better samples like src\mono\sample\wasm\browser\main.js
- * This one is not ES6 nor CJS, doesn't use top level await and has edge case polyfills.
+ * This one is not ES6 nor CJS, doesn't use top level await and has edge case polyfills.
* It handles strange things which happen with XHarness.
****************************************************************************/
@@ -63,19 +63,21 @@ async function getArgs() {
queryArguments = Array.from(WScript.Arguments);
}
- let runArgs;
- if (queryArguments.length > 0) {
- runArgs = processArguments(queryArguments);
- } else {
- const response = fetch('/runArgs.json')
- if (!response.ok) {
- console.debug(`could not load /args.json: ${response.status}. Ignoring`);
+ let runArgsJson;
+ // ToDo: runArgs should be read for all kinds of hosts, but
+ // fetch is added to node>=18 and current Windows's emcc node<18
+ if (is_browser)
+ {
+ const response = await globalThis.fetch('./runArgs.json');
+ if (response.ok) {
+ runArgsJson = initRunArgs(await response.json());
+ } else {
+ console.debug(`could not load /runArgs.json: ${response.status}. Ignoring`);
}
- runArgs = await response.json();
}
- runArgs = initRunArgs(runArgs);
-
- return runArgs;
+ if (!runArgsJson)
+ runArgsJson = initRunArgs({});
+ return processArguments(queryArguments, runArgsJson);
}
function initRunArgs(runArgs) {
@@ -95,9 +97,7 @@ function initRunArgs(runArgs) {
return runArgs;
}
-function processArguments(incomingArguments) {
- const runArgs = initRunArgs({});
-
+function processArguments(incomingArguments, runArgs) {
console.log("Incoming arguments: " + incomingArguments.join(' '));
while (incomingArguments && incomingArguments.length > 0) {
const currentArg = incomingArguments[0];
@@ -343,4 +343,4 @@ async function run() {
}
}
-run();
\ No newline at end of file
+run();