Skip to content
Merged
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
2 changes: 2 additions & 0 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ extends:
extraBuildArgs: /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
scenarios:
- WasmTestOnChrome
- WasmTestOnFirefox
- WasmTestOnV8

# EAT Library tests - only run on linux
- template: /eng/pipelines/common/templates/wasm-library-aot-tests.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public void Properties_SetOptionsAndGetTheirValue_NotSet_EnableStreamingResponse
Assert.False(streamingEnabledValue);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNodeJS))] // not V8 shell
public async Task HttpStreamingDisabledBy_WasmEnableStreamingResponse_InProject()
{
using var client = new HttpClient();
Expand All @@ -309,7 +309,7 @@ public async Task HttpStreamingDisabledBy_WasmEnableStreamingResponse_InProject(
Assert.True(stream.CanSeek);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNodeJS))] // not V8 shell
public async Task HttpStreamingEnabledBy_WebAssemblyEnableStreamingResponse_Option()
{
using var client = new HttpClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public unsafe void StructSize()
Assert.Equal(32, sizeof(JSMarshalerArgument));
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNodeJS))] // not V8 shell
public unsafe void PrototypeNotEqual()
{
using var temp1 = JSHost.GlobalThis.GetPropertyAsJSObject("EventTarget");
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/sendtohelix-browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<NeedsEMSDKNode Condition="'$(Scenario)' == 'BuildWasmApps'">false</NeedsEMSDKNode>
<NeedsToRunOnChrome Condition="'$(Scenario)' == 'WasmTestOnChrome' or '$(Scenario)' == 'BuildWasmApps'">true</NeedsToRunOnChrome>
<NeedsToRunOnFirefox Condition="'$(Scenario)' == 'WasmTestOnFirefox'">true</NeedsToRunOnFirefox>
<NeedsToRunOnV8 Condition="'$(Scenario)' == '' or '$(Scenario)' == 'normal' or '$(Scenario)' == 'BuildWasmApps'">true</NeedsToRunOnV8>
<NeedsToRunOnV8 Condition="'$(Scenario)' == '' or '$(Scenario)' == 'normal' or '$(Scenario)' == 'BuildWasmApps' or '$(Scenario)' == 'WasmTestOnV8'">true</NeedsToRunOnV8>
<NeedsBuiltNugets Condition="'$(Scenario)' == 'BuildWasmApps'">true</NeedsBuiltNugets>

<IncludeXHarnessCli>true</IncludeXHarnessCli>
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { mono_log_debug } from "./logging";
function verifyEnvironment () {
if (typeof globalThis.fetch !== "function" || typeof globalThis.AbortController !== "function") {
const message = ENVIRONMENT_IS_NODE
? "Please install `node-fetch` and `node-abort-controller` npm packages to enable HTTP client support. See also https://aka.ms/dotnet-wasm-features"
: "This browser doesn't support fetch API. Please use a modern browser. See also https://aka.ms/dotnet-wasm-features";
? "Please install `node-fetch` and `node-abort-controller` npm packages to enable HTTP client support."
: "This browser doesn't support fetch API. Please use a modern browser. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms";
throw new Error(message);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/mono/browser/runtime/loader/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ const URLPolyfill = class URL {
};

export function verifyEnvironment () {
mono_assert(ENVIRONMENT_IS_SHELL || typeof globalThis.URL === "function", "This browser/engine doesn't support URL API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features");
mono_assert(typeof globalThis.BigInt64Array === "function", "This browser/engine doesn't support BigInt64Array API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features");
mono_assert(ENVIRONMENT_IS_SHELL || typeof globalThis.URL === "function", "This browser/engine doesn't support URL API. Please use a modern version.");
mono_assert(typeof globalThis.BigInt64Array === "function", "This browser/engine doesn't support BigInt64Array API. Please use a modern version. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms");
mono_assert(globalThis.performance && typeof globalThis.performance.now === "function", "This browser/engine doesn't support performance.now. Please use a modern version.");
mono_assert(ENVIRONMENT_IS_SHELL || globalThis.crypto && typeof globalThis.crypto.subtle === "object", "This engine doesn't support crypto.subtle. Please use a modern version.");
mono_assert(ENVIRONMENT_IS_SHELL || globalThis.crypto && typeof globalThis.crypto.getRandomValues === "function", "This engine doesn't support crypto.getRandomValues. Please use a modern version.");
if (ENVIRONMENT_IS_NODE) {
mono_assert(typeof process.exit === "function", "This engine doesn't support process.exit. Please use a modern version.");
}
if (WasmEnableThreads) {
mono_assert(!ENVIRONMENT_IS_SHELL && !ENVIRONMENT_IS_NODE, "This build of dotnet is multi-threaded, it doesn't support shell environments like V8 or NodeJS. See also https://aka.ms/dotnet-wasm-features");
mono_assert(globalThis.SharedArrayBuffer !== undefined, "SharedArrayBuffer is not enabled on this page. Please use a modern browser and set Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy http headers. See also https://aka.ms/dotnet-wasm-features");
mono_assert(typeof globalThis.EventTarget === "function", "This browser/engine doesn't support EventTarget API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features");
mono_assert(!ENVIRONMENT_IS_SHELL && !ENVIRONMENT_IS_NODE, "This build of dotnet is multi-threaded, it doesn't support shell environments like V8 or NodeJS.");
mono_assert(globalThis.SharedArrayBuffer !== undefined, "SharedArrayBuffer is not enabled on this page. Please use a modern browser and set Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy http headers.");
mono_assert(typeof globalThis.EventTarget === "function", "This browser/engine doesn't support EventTarget API. Please use a modern version. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms");
}
}

Expand All @@ -41,7 +41,7 @@ export async function detect_features_and_polyfill (module: DotnetModuleInternal
const process = await import(/*! webpackIgnore: true */"process");
const minNodeVersion = 14;
if (process.versions.node.split(".")[0] < minNodeVersion) {
throw new Error(`NodeJS at '${process.execPath}' has too low version '${process.versions.node}', please use at least ${minNodeVersion}. See also https://aka.ms/dotnet-wasm-features`);
throw new Error(`NodeJS at '${process.execPath}' has too low version '${process.versions.node}', please use at least ${minNodeVersion}.`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ async function initializeModules (es6Modules: [RuntimeModuleExportsInternal, Nat
});
result.catch((error) => {
if (error.message && error.message.toLowerCase().includes("out of memory")) {
throw new Error(".NET runtime has failed to start, because too much memory was requested. Please decrease the memory by adjusting EmccMaximumHeapSize. See also https://aka.ms/dotnet-wasm-features");
throw new Error(".NET runtime has failed to start, because too much memory was requested. Please decrease the memory by adjusting EmccMaximumHeapSize.");
}
throw error;
});
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export function configureEmscriptenStartup (module: DotnetModuleInternal): void
mono_log_warn(`The threads of dotnet.native.js ${runtimeHelpers.emscriptenBuildOptions.wasmEnableThreads} is different from the version of dotnet.runtime.js ${WasmEnableThreads}!`);
}
if (runtimeHelpers.emscriptenBuildOptions.wasmEnableSIMD) {
mono_assert(runtimeHelpers.featureWasmSimd, "This browser/engine doesn't support WASM SIMD. Please use a modern version. See also https://aka.ms/dotnet-wasm-features");
mono_assert(runtimeHelpers.featureWasmSimd, "This browser/engine doesn't support WASM SIMD. Please use a modern version. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms");
}
if (runtimeHelpers.emscriptenBuildOptions.wasmEnableEH) {
mono_assert(runtimeHelpers.featureWasmEh, "This browser/engine doesn't support WASM exception handling. Please use a modern version. See also https://aka.ms/dotnet-wasm-features");
mono_assert(runtimeHelpers.featureWasmEh, "This browser/engine doesn't support WASM exception handling. Please use a modern version. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms");
}
module.mainScriptUrlOrBlob = loaderHelpers.scriptUrl;// this is needed by worker threads

Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/web-socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function verifyEnvironment () {
}
if (typeof globalThis.WebSocket !== "function") {
const message = ENVIRONMENT_IS_NODE
? "Please install `ws` npm package to enable networking support. See also https://aka.ms/dotnet-wasm-features"
: "This browser doesn't support WebSocket API. Please use a modern browser. See also https://aka.ms/dotnet-wasm-features";
? "Please install `ws` npm package to enable networking support."
: "This browser doesn't support WebSocket API. Please use a modern browser. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms";
throw new Error(message);
}
}
Expand Down
16 changes: 13 additions & 3 deletions src/native/libs/Common/JavaScript/loader/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { exceptions, simd } from "wasm-feature-detect";

import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL } from "./per-module";
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, globalThisAny } from "./per-module";
import { dotnetAssert } from "./cross-module";

const scriptUrlQuery = /*! webpackIgnore: true */import.meta.url;
Expand All @@ -13,8 +13,18 @@ const scriptUrl = normalizeFileUrl(scriptUrlQuery);
const scriptDirectory = normalizeDirectoryUrl(scriptUrl);

export async function validateWasmFeatures(): Promise<void> {
dotnetAssert.check(await exceptions, "This browser/engine doesn't support WASM exception handling. Please use a modern version. See also https://aka.ms/dotnet-wasm-features");
dotnetAssert.check(await simd, "This browser/engine doesn't support WASM SIMD. Please use a modern version. See also https://aka.ms/dotnet-wasm-features");
dotnetAssert.check(await exceptions(), "This browser/engine doesn't support WASM exception handling. Please use a modern version. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms");
dotnetAssert.check(await simd(), "This browser/engine doesn't support WASM SIMD. Please use a modern version. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms");
if (ENVIRONMENT_IS_NODE) {
const nodeMajorVersion = parseInt(globalThisAny.process.versions.node.split(".")[0], 10);
dotnetAssert.check(nodeMajorVersion >= 18, `Node.js version ${globalThisAny.process.versions.node} is not supported. Please use Node.js 18 or later.`);
} else if (ENVIRONMENT_IS_SHELL) {
if (typeof globalThisAny.version === "function" && globalThisAny.d8) {
const v8v = globalThisAny.version();
const v8MajorVersion = parseInt(v8v.split(".")[0], 10);
dotnetAssert.check(v8MajorVersion >= 14, "This V8 shell is too old. Please use a modern version.");
}
}
}

export function locateFile(path: string, isModule = false): string {
Expand Down
2 changes: 1 addition & 1 deletion src/native/libs/Common/JavaScript/loader/exit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function exit(exitCode: number, reason: any): void {
}
}
if (!runtimeState.dotnetReady) {
dotnetLogger.debug(() => `Aborting startup, reason: ${reason}`);
dotnetLogger.info(`Aborting startup, reason: ${reason}`);
dotnetLoaderExports.abortStartup(reason);
}
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/native/libs/Common/JavaScript/loader/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export async function fetchLike(url: string, init?: RequestInit, expectedContent
} else if (hasFetch) {
return globalThis.fetch(url, init || { credentials: "same-origin" });
} else if (typeof (read) === "function") {
const isText = expectedContentType === "application/json" || expectedContentType === "text/plain";
const isText = expectedContentType && (expectedContentType.startsWith("application/json") || expectedContentType.startsWith("text/plain"));
const arrayBuffer = read(url, isText ? "utf8" : "binary");
return responseLike(url, arrayBuffer, {
status: 200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { dotnetLogger, dotnetAssert } from "./cross-module";
function verifyEnvironment() {
if (typeof globalThis.fetch !== "function" || typeof globalThis.AbortController !== "function") {
const message = ENVIRONMENT_IS_NODE
? "Please install `node-fetch` and `node-abort-controller` npm packages to enable HTTP client support. See also https://aka.ms/dotnet-wasm-features"
: "This browser doesn't support fetch API. Please use a modern browser. See also https://aka.ms/dotnet-wasm-features";
? "Please install `node-fetch` and `node-abort-controller` npm packages to enable HTTP client support."
: "This browser doesn't support fetch API. Please use a modern browser. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms";
throw new Error(message);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ function verifyEnvironment() {
}
if (typeof globalThis.WebSocket !== "function") {
const message = ENVIRONMENT_IS_NODE
? "Please install `ws` npm package to enable networking support. See also https://aka.ms/dotnet-wasm-features"
: "This browser doesn't support WebSocket API. Please use a modern browser. See also https://aka.ms/dotnet-wasm-features";
? "Please install `ws` npm package to enable networking support."
: "This browser doesn't support WebSocket API. Please use a modern browser. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms";
throw new Error(message);
}
}
Loading