Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public async Task MissingImportAsync()
Assert.Contains("intentionallyMissingImportAsync must be a Function but was undefined", ex.Message);
}

[Fact]
public void EmptyModuleNameImport()
{
Assert.Equal("empty module", JavaScriptTestHelper.EmptyModuleNameEcho("empty module"));
}

#if !FEATURE_WASM_MANAGED_THREADS // because in MT JSHost.ImportAsync is really async, it will finish before the caller could cancel it
[Fact]
public async Task CancelableImportAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public static void ConsoleWriteLine([JSMarshalAs<JSType.String>] string message)
[JSImport("intentionallyMissingImportAsync", "JavaScriptTestHelper")]
public static partial Task IntentionallyMissingImportAsync();

[JSImport("emptyModuleNameEcho", "")]
public static partial string EmptyModuleNameEcho(string message);

[JSImport("catch1toString", "JavaScriptTestHelper")]
public static partial string catch1toString(string message, string functionName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@ globalThis.rebound = {

export async function setup() {
dllExports = await App.runtime.getAssemblyExports("System.Runtime.InteropServices.JavaScript.Tests.dll");
App.runtime.setModuleImports("", { emptyModuleNameEcho });
}

function emptyModuleNameEcho(message) {
return message;
}

// console.log('JavaScriptTestHelper:' Object.keys(globalThis.JavaScriptTestHelper));
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/invoke-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ function mono_wasm_lookup_js_import (function_name: string, js_module_name: stri

let scope: any = {};
const parts = function_name.split(".");
if (js_module_name) {
if (js_module_name != null) {
scope = importedModules.get(js_module_name);
if (WasmEnableThreads) {
mono_assert(scope, () => `ES6 module ${js_module_name} was not imported yet, please call JSHost.ImportAsync() on the UI or JSWebWorker thread first in order to invoke ${function_name}.`);
Comment on lines +385 to 388
Expand Down
Loading