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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<DefineConstants>$(DefineConstants);TARGET_BROWSER</DefineConstants>
<!-- This WASM test is slow on NodeJS. This sets the xharness timeout but there is also override in sendtohelix-browser.targets -->
<WasmXHarnessTestsTimeout>01:15:00</WasmXHarnessTestsTimeout>
<XunitShowProgress Condition="'$(FeatureWasmManagedThreads)' == 'true'">true</XunitShowProgress>
<XunitShowProgress Condition="'$(RuntimeFlavor)' == 'CoreCLR'">true</XunitShowProgress>
<!-- Enable diagnostic features. They will add appropriate RuntimeHostConfigurationOption values to runtime config and ILLink.
https://github.com/dotnet/docs/blob/main/docs/core/deploying/trimming/trimming-options.md#trim-framework-library-features
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ internal static partial class BrowserInterop
{
return null;
}
if (!webSocket.HasProperty("close_status"))
if (!webSocket.HasProperty("closeStatus"))
{
return null;
}

int status = webSocket.GetPropertyAsInt32("close_status");
int status = webSocket.GetPropertyAsInt32("closeStatus");
return (WebSocketCloseStatus)status;
}

Expand All @@ -42,7 +42,7 @@ internal static partial class BrowserInterop
return null;
}

string? description = webSocket.GetPropertyAsString("close_status_description");
string? description = webSocket.GetPropertyAsString("closeStatusDescription");
return description;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<TestArchiveTestsDir>$(TestArchiveTestsRoot)$(OSPlatformConfig)/</TestArchiveTestsDir>
<DefineConstants>$(DefineConstants);TARGET_BROWSER</DefineConstants>
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
<XunitShowProgress Condition="'$(RuntimeFlavor)' == 'CoreCLR'">true</XunitShowProgress>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- Use following lines to write the generated files to disk. -->
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<WasmXHarnessMaxParallelThreads>1</WasmXHarnessMaxParallelThreads>
<XunitShowProgress Condition="'$(FeatureWasmManagedThreads)' == 'true'">true</XunitShowProgress>
<XunitShowProgress Condition="'$(RuntimeFlavor)' == 'CoreCLR'">true</XunitShowProgress>
<NoWarn>$(NoWarn);IL2103;IL2025;IL2111;IL2122</NoWarn>
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
<!-- This test library intentionally references inbox P2Ps as it needs the implementation, instead of the contract.
Expand Down Expand Up @@ -58,8 +58,7 @@

<ItemGroup Condition="'$(FeatureWasmManagedThreads)' != 'true'">
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\JavaScript\SecondRuntimeTest.cs" />
<!-- WASM-TODO: https://github.com/dotnet/runtime/issues/120216 -->
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\JavaScript\HttpRequestMessageTest.cs" Condition="'$(RuntimeFlavor)' == 'Mono'"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\JavaScript\HttpRequestMessageTest.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\JavaScript\TimerTests.cs" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@
<SmokeTestProject Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices.JavaScript\tests\System.Runtime.InteropServices.JavaScript.UnitTests\System.Runtime.InteropServices.JavaScript.Tests.csproj" />
<SmokeTestProject Include="$(MSBuildThisFileDirectory)System.Threading\tests\System.Threading.Tests.csproj" />
<SmokeTestProject Include="$(MSBuildThisFileDirectory)System.Runtime\tests\System.Threading.Tasks.Tests\System.Threading.Tasks.Tests.csproj" />
<SmokeTestProject Include="$(MSBuildThisFileDirectory)System.Net.Http\tests\FunctionalTests\System.Net.Http.Functional.Tests.csproj" />
<SmokeTestProject Include="$(MSBuildThisFileDirectory)System.Net.WebSockets.Client\tests\System.Net.WebSockets.Client.Tests.csproj" />
</ItemGroup>

<!-- wasi/interp smoke tests -->
Expand Down
8 changes: 4 additions & 4 deletions src/mono/browser/runtime/web-socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export function ws_wasm_create (uri: string, sub_protocols: string[] | null, rec
forceThreadMemoryViewRefresh();

ws[wasm_ws_close_received] = true;
ws["close_status"] = ev.code;
ws["close_status_description"] = ev.reason;
ws["closeStatus"] = ev.code;
ws["closeStatusDescription"] = ev.reason;

if (ws[wasm_ws_pending_open_promise_used]) {
open_promise_control.reject(new Error(ev.reason));
Expand Down Expand Up @@ -492,8 +492,8 @@ type WebSocketExtension = WebSocket & {
[wasm_ws_pending_send_buffer_offset]: number
[wasm_ws_pending_send_buffer_type]: number
[wasm_ws_pending_send_buffer]: Uint8Array | null
["close_status"]: number | undefined
["close_status_description"]: string | undefined
["closeStatus"]: number | undefined
["closeStatusDescription"]: string | undefined
dispose(): void
}

Expand Down
11 changes: 7 additions & 4 deletions src/native/corehost/browserhost/loader/exit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

import type { OnExitListener } from "../types";
import { dotnetLogger, dotnetLoaderExports, Module, dotnetBrowserUtilsExports } from "./cross-module";
import { dotnetLogger, dotnetLoaderExports, Module, dotnetBrowserUtilsExports, dotnetRuntimeExports } from "./cross-module";
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_WEB } from "./per-module";

export const runtimeState = {
Expand Down Expand Up @@ -106,6 +106,12 @@ export function exit(exitCode: number, reason: any): void {
runtimeState.exitReason = reason;

try {
if (dotnetRuntimeExports && dotnetRuntimeExports.abortInteropTimers) {
dotnetRuntimeExports.abortInteropTimers();
}
if (dotnetBrowserUtilsExports && dotnetBrowserUtilsExports.abortBackgroundTimers) {
dotnetBrowserUtilsExports.abortBackgroundTimers();
}
unregisterExit();
if (!alreadySilent) {
if (runtimeState.onExitListeners.length === 0 && !runtimeState.runtimeReady) {
Expand Down Expand Up @@ -144,9 +150,6 @@ export function exit(exitCode: number, reason: any): void {
export function quitNow(exitCode: number, reason?: any): void {
if (runtimeState.runtimeReady) {
Module.runtimeKeepalivePop();
if (dotnetBrowserUtilsExports && dotnetBrowserUtilsExports.abortTimers) {
dotnetBrowserUtilsExports.abortTimers();
}
if (dotnetBrowserUtilsExports && dotnetBrowserUtilsExports.abortPosix) {
dotnetBrowserUtilsExports.abortPosix(exitCode);
}
Expand Down
4 changes: 4 additions & 0 deletions src/native/libs/Common/JavaScript/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ set(ROLLUP_TS_SOURCES
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/cancelable-promise.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/cross-module.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/gc-handles.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/http.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/invoke-cs.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/invoke-js.ts"
Expand All @@ -90,9 +91,12 @@ set(ROLLUP_TS_SOURCES
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshal.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshaled-types.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/per-module.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/queue.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/scheduling.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/types.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/utils.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/weak-ref.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/web-socket.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/types.ts"
)
Expand Down
4 changes: 3 additions & 1 deletion src/native/libs/Common/JavaScript/cross-module/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export function dotnetUpdateInternalsSubscriber() {
cancelPromise: table[4],
invokeJSFunction: table[5],
forceDisposeProxies: table[6],
abortInteropTimers: table[7],
};
Object.assign(runtime, runtimerLocal);
}
Expand Down Expand Up @@ -191,9 +192,10 @@ export function dotnetUpdateInternalsSubscriber() {
stringToUTF8: table[4],
zeroRegion: table[5],
isSharedArrayBuffer: table[6],
abortTimers: table[7],
abortBackgroundTimers: table[7],
abortPosix: table[8],
getExitStatus: table[9],
runBackgroundTimers: table[10],
};
Object.assign(interop, interopLocal);
}
Expand Down
11 changes: 8 additions & 3 deletions src/native/libs/Common/JavaScript/types/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import type { createPromiseCompletionSource, getPromiseCompletionSource, isContr

import type { isSharedArrayBuffer, zeroRegion } from "../../../System.Native.Browser/utils/memory";
import type { stringToUTF16, stringToUTF16Ptr, stringToUTF8, stringToUTF8Ptr, utf16ToString } from "../../../System.Native.Browser/utils/strings";
import type { abortPosix, abortTimers, getExitStatus } from "../../../System.Native.Browser/utils/host";
import type { abortPosix, abortBackgroundTimers, getExitStatus, runBackgroundTimers } from "../../../System.Native.Browser/utils/host";
import type { bindJSImportST, invokeJSFunction, invokeJSImportST } from "../../../System.Runtime.InteropServices.JavaScript.Native/interop/invoke-js";
import type { forceDisposeProxies, releaseCSOwnedObject } from "../../../System.Runtime.InteropServices.JavaScript.Native/interop/gc-handles";
import type { resolveOrRejectPromise } from "../../../System.Runtime.InteropServices.JavaScript.Native/interop/marshal-to-js";
import type { cancelPromise } from "../../../System.Runtime.InteropServices.JavaScript.Native/interop/cancelable-promise";
import type { abortInteropTimers } from "../../../System.Runtime.InteropServices.JavaScript.Native/interop/scheduling";

import type { symbolicateStackTrace } from "../../../System.Native.Browser/diagnostics/symbolicate";
import type { EmsAmbientSymbolsType } from "../types";
Expand All @@ -27,6 +28,7 @@ export type RuntimeExports = {
cancelPromise: typeof cancelPromise,
invokeJSFunction: typeof invokeJSFunction,
forceDisposeProxies: typeof forceDisposeProxies,
abortInteropTimers: typeof abortInteropTimers,
}

export type RuntimeExportsTable = [
Expand All @@ -37,6 +39,7 @@ export type RuntimeExportsTable = [
typeof cancelPromise,
typeof invokeJSFunction,
typeof forceDisposeProxies,
typeof abortInteropTimers,
]

export type LoggerType = {
Expand Down Expand Up @@ -133,9 +136,10 @@ export type BrowserUtilsExports = {
stringToUTF8: typeof stringToUTF8,
zeroRegion: typeof zeroRegion,
isSharedArrayBuffer: typeof isSharedArrayBuffer
abortTimers: typeof abortTimers,
abortBackgroundTimers: typeof abortBackgroundTimers,
abortPosix: typeof abortPosix,
getExitStatus: typeof getExitStatus,
runBackgroundTimers: typeof runBackgroundTimers,
}

export type BrowserUtilsExportsTable = [
Expand All @@ -146,9 +150,10 @@ export type BrowserUtilsExportsTable = [
typeof stringToUTF8,
typeof zeroRegion,
typeof isSharedArrayBuffer,
typeof abortTimers,
typeof abortBackgroundTimers,
typeof abortPosix,
typeof getExitStatus,
typeof runBackgroundTimers,
]

export type DiagnosticsExportsTable = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
const exports = {};
libNativeBrowser(exports);

let commonDeps = ["$BROWSER_UTILS", "SystemJS_ExecuteTimerCallback", "SystemJS_ExecuteBackgroundJobCallback"];
let commonDeps = [
"$BROWSER_UTILS",
"SystemJS_ExecuteTimerCallback", "SystemJS_ExecuteBackgroundJobCallback"
];
const lib = {
$DOTNET: {
selfInitialize: () => {
Expand Down
1 change: 0 additions & 1 deletion src/native/libs/System.Native.Browser/native/scheduling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ export function SystemJS_ScheduleBackgroundJob(): void {
_ems_._SystemJS_ExecuteBackgroundJobCallback();
}
}

7 changes: 6 additions & 1 deletion src/native/libs/System.Native.Browser/utils/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export function getExitStatus(): new (exitCode: number) => any {
return _ems_.ExitStatus as any;
}

export function abortTimers(): void {
export function runBackgroundTimers(): void {
_ems_._SystemJS_ExecuteTimerCallback();
_ems_._SystemJS_ExecuteBackgroundJobCallback();
}

export function abortBackgroundTimers(): void {
if (_ems_.DOTNET.lastScheduledTimerId) {
globalThis.clearTimeout(_ems_.DOTNET.lastScheduledTimerId);
_ems_.runtimeKeepalivePop();
Expand Down
8 changes: 5 additions & 3 deletions src/native/libs/System.Native.Browser/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
isSharedArrayBuffer,
} from "./memory";
import { stringToUTF16, stringToUTF16Ptr, stringToUTF8, stringToUTF8Ptr, utf16ToString } from "./strings";
import { abortPosix, abortTimers, getExitStatus, setEnvironmentVariable } from "./host";
import { abortPosix, abortBackgroundTimers, getExitStatus, setEnvironmentVariable, runBackgroundTimers } from "./host";
import { dotnetUpdateInternals, dotnetUpdateInternalsSubscriber } from "../utils/cross-module";
import { initPolyfills } from "../utils/polyfills";
import { registerRuntime } from "./runtime-list";
Expand Down Expand Up @@ -50,9 +50,10 @@ export function dotnetInitializeModule(internals: InternalExchange): void {
stringToUTF8,
zeroRegion,
isSharedArrayBuffer,
abortTimers,
abortBackgroundTimers,
abortPosix,
getExitStatus,
runBackgroundTimers,
});
dotnetUpdateInternals(internals, dotnetUpdateInternalsSubscriber);
function browserUtilsExportsToTable(map: BrowserUtilsExports): BrowserUtilsExportsTable {
Expand All @@ -65,9 +66,10 @@ export function dotnetInitializeModule(internals: InternalExchange): void {
map.stringToUTF8,
map.zeroRegion,
map.isSharedArrayBuffer,
map.abortTimers,
map.abortBackgroundTimers,
map.abortPosix,
map.getExitStatus,
map.runBackgroundTimers,
];
}
}
Expand Down
Loading
Loading