diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/HelperMarshal.cs b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/HelperMarshal.cs index 3c359f2f0b9e4..2f2c99650a7df 100644 --- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/HelperMarshal.cs +++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/HelperMarshal.cs @@ -307,6 +307,213 @@ private static void GetTypedArrayDouble(JSObject obj) _taDouble = ((Float64Array)obj.GetObjectProperty("typedArray")).ToArray(); } + private static void SetUint8ClampedArray(JSObject obj, int length) + { + var clamped = new byte[length]; + obj.SetObjectProperty("clampedArray", Uint8ClampedArray.From(clamped)); + } + + internal static Uint8ClampedArray _caUInt; + private static void GetUint8ClampedArray(JSObject obj) + { + _caUInt = (Uint8ClampedArray)obj.GetObjectProperty("clampedArray"); + } + + private static void SetUint8Array(JSObject obj, int length) + { + var array = new byte[length]; + obj.SetObjectProperty("uint8Array", Uint8Array.From(array)); + } + + internal static Uint8Array _uint8Array; + private static void GetUint8Array(JSObject obj) + { + _uint8Array = (Uint8Array)obj.GetObjectProperty("uint8Array"); + } + + private static void SetUint16Array(JSObject obj, int length) + { + var array = new ushort[length]; + obj.SetObjectProperty("uint16Array", Uint16Array.From(array)); + } + + internal static Uint16Array _uint16Array; + private static void GetUint16Array(JSObject obj) + { + _uint16Array = (Uint16Array)obj.GetObjectProperty("uint16Array"); + } + + private static void SetUint32Array(JSObject obj, int length) + { + var array = new uint[length]; + obj.SetObjectProperty("uint32Array", Uint32Array.From(array)); + } + + internal static Uint32Array _uint32Array; + private static void GetUint32Array(JSObject obj) + { + _uint32Array = (Uint32Array)obj.GetObjectProperty("uint32Array"); + } + + private static void SetInt8Array(JSObject obj, int length) + { + var array = new sbyte[length]; + obj.SetObjectProperty("int8Array", Int8Array.From(array)); + } + + internal static Int8Array _int8Array; + private static void GetInt8Array(JSObject obj) + { + _int8Array = (Int8Array)obj.GetObjectProperty("int8Array"); + } + + private static void SetInt16Array(JSObject obj, int length) + { + var array = new short[length]; + obj.SetObjectProperty("int16Array", Int16Array.From(array)); + } + + internal static Int16Array _int16Array; + private static void GetInt16Array(JSObject obj) + { + _int16Array = (Int16Array)obj.GetObjectProperty("int16Array"); + } + + private static void SetInt32Array(JSObject obj, int length) + { + var array = new int[length]; + obj.SetObjectProperty("int32Array", Int32Array.From(array)); + } + + internal static Int32Array _int32Array; + private static void GetInt32Array(JSObject obj) + { + _int32Array = (Int32Array)obj.GetObjectProperty("int32Array"); + } + + private static void SetFloat32Array(JSObject obj, int length) + { + var array = new float[length]; + obj.SetObjectProperty("float32Array", Float32Array.From(array)); + } + + internal static Float32Array _float32Array; + private static void GetFloat32Array(JSObject obj) + { + _float32Array = (Float32Array)obj.GetObjectProperty("float32Array"); + } + + private static void SetFloat64Array(JSObject obj, int length) + { + var array = new double[length]; + obj.SetObjectProperty("float64Array", Float64Array.From(array)); + } + + internal static Float64Array _float64Array; + private static void GetFloat64Array(JSObject obj) + { + _float64Array = (Float64Array)obj.GetObjectProperty("float64Array"); + } + + private static void SetUint8ClampedArrayFromSharedArrayBuffer(JSObject obj, int length) + { + obj.SetObjectProperty("clampedArrayFromSharedArrayBuffer", new Uint8ClampedArray(new SharedArrayBuffer(length))); + } + + internal static Uint8ClampedArray _caFromSharedArrayBuffer; + private static void GetUint8ClampedArrayFromSharedArrayBuffer(JSObject obj) + { + _caFromSharedArrayBuffer = (Uint8ClampedArray)obj.GetObjectProperty("clampedArrayFromSharedArrayBuffer"); + } + + private static void SetUint8ArrayFromSharedArrayBuffer(JSObject obj, int length) + { + obj.SetObjectProperty("uint8ArrayFromSharedArrayBuffer", new Uint8Array(new SharedArrayBuffer(length))); + } + + internal static Uint8Array _uint8FromSharedArrayBuffer; + private static void GetUint8ArrayFromSharedArrayBuffer(JSObject obj) + { + _uint8FromSharedArrayBuffer = (Uint8Array)obj.GetObjectProperty("uint8ArrayFromSharedArrayBuffer"); + } + + private static void SetUint16ArrayFromSharedArrayBuffer(JSObject obj, int length) + { + obj.SetObjectProperty("uint16ArrayFromSharedArrayBuffer", new Uint16Array(new SharedArrayBuffer(length))); + } + + internal static Uint16Array _uint16FromSharedArrayBuffer; + private static void GetUint16ArrayFromSharedArrayBuffer(JSObject obj) + { + _uint16FromSharedArrayBuffer = (Uint16Array)obj.GetObjectProperty("uint16ArrayFromSharedArrayBuffer"); + } + + private static void SetUint32ArrayFromSharedArrayBuffer(JSObject obj, int length) + { + obj.SetObjectProperty("uint32ArrayFromSharedArrayBuffer", new Uint32Array(new SharedArrayBuffer(length))); + } + + internal static Uint32Array _uint32FromSharedArrayBuffer; + private static void GetUint32ArrayFromSharedArrayBuffer(JSObject obj) + { + _uint32FromSharedArrayBuffer = (Uint32Array)obj.GetObjectProperty("uint32ArrayFromSharedArrayBuffer"); + } + + private static void SetInt8ArrayFromSharedArrayBuffer(JSObject obj, int length) + { + obj.SetObjectProperty("int8ArrayFromSharedArrayBuffer", new Int8Array(new SharedArrayBuffer(length))); + } + + internal static Int8Array _int8fromSharedArrayBuffer; + private static void GetInt8ArrayFromSharedArrayBuffer(JSObject obj) + { + _int8fromSharedArrayBuffer = (Int8Array)obj.GetObjectProperty("int8ArrayFromSharedArrayBuffer"); + } + + private static void SetInt16ArrayFromSharedArrayBuffer(JSObject obj, int length) + { + obj.SetObjectProperty("int16ArrayFromSharedArrayBuffer", new Int16Array(new SharedArrayBuffer(length))); + } + + internal static Int16Array _int16fromSharedArrayBuffer; + private static void GetInt16ArrayFromSharedArrayBuffer(JSObject obj) + { + _int16fromSharedArrayBuffer = (Int16Array)obj.GetObjectProperty("int16ArrayFromSharedArrayBuffer"); + } + + private static void SetInt32ArrayFromSharedArrayBuffer(JSObject obj, int length) + { + obj.SetObjectProperty("int32ArrayFromSharedArrayBuffer", new Int32Array(new SharedArrayBuffer(length))); + } + + internal static Int32Array _int32fromSharedArrayBuffer; + private static void GetInt32ArrayFromSharedArrayBuffer(JSObject obj) + { + _int32fromSharedArrayBuffer = (Int32Array)obj.GetObjectProperty("int32ArrayFromSharedArrayBuffer"); + } + + private static void SetFloat32ArrayFromSharedArrayBuffer(JSObject obj, int length) + { + obj.SetObjectProperty("float32ArrayFromSharedArrayBuffer", new Float32Array(new SharedArrayBuffer(length))); + } + + internal static Float32Array _float32fromSharedArrayBuffer; + private static void GetFloat32ArrayFromSharedArrayBuffer(JSObject obj) + { + _float32fromSharedArrayBuffer = (Float32Array)obj.GetObjectProperty("float32ArrayFromSharedArrayBuffer"); + } + + private static void SetFloat64ArrayFromSharedArrayBuffer(JSObject obj, int length) + { + obj.SetObjectProperty("float64ArrayFromSharedArrayBuffer", new Float64Array(new SharedArrayBuffer(length))); + } + + internal static Float64Array _float64fromSharedArrayBuffer; + private static void GetFloat64ArrayFromSharedArrayBuffer(JSObject obj) + { + _float64fromSharedArrayBuffer = (Float64Array)obj.GetObjectProperty("float64ArrayFromSharedArrayBuffer"); + } + private static Function _sumFunction; private static void CreateFunctionSum() { @@ -346,4 +553,6 @@ public static void SetBlobAsUri(Uri blobUri) } } + + } diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/Http/HttpRequestMessageTest.cs b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/Http/HttpRequestMessageTest.cs index 42e34d74156dd..aeb9b72475b4f 100644 --- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/Http/HttpRequestMessageTest.cs +++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/Http/HttpRequestMessageTest.cs @@ -409,6 +409,55 @@ function typedArrayToURL(typedArray, mimeType) { Assert.Equal (59, content.Length); } + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + public async Task BlobUri_Marshal_CorrectBinaryData_Browser() + { + Runtime.InvokeJS(@" + function arrayBufferToURL(arrayBuffer, mimeType) { + return URL.createObjectURL(new Blob([arrayBuffer], {type: mimeType})) + } + var myArray = new ArrayBuffer(512); + var longInt8View = new Uint8Array(myArray); + // generate some data + for (var i=0; i< longInt8View.length; i++) { + longInt8View[i] = i % 256; + } + const url = arrayBufferToURL(myArray, 'text/plain') + App.call_test_method (""InvokeString"", [ url ]); + + "); + var client = new HttpClient (); + Assert.StartsWith ("blob:", HelperMarshal._stringResource); + Console.WriteLine(HelperMarshal._stringResource); + HttpRequestMessage rm = new HttpRequestMessage(HttpMethod.Get, new Uri (HelperMarshal._stringResource)); + HttpResponseMessage resp = await client.SendAsync (rm); + Assert.NotNull (resp.Content); + string content = await resp.Content.ReadAsStringAsync(); + Assert.Equal (512, content.Length); + } + + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + public async Task BlobUri_Marshal_CorrectHeader_Browser() + { + Runtime.InvokeJS(@" + function JSONToURL(obj) { + return URL.createObjectURL(new Blob([JSON.stringify(obj)], {type: 'application/json'})) + } + + const obj = {hello: 'world'}; + const url = JSONToURL (obj); + App.call_test_method (""InvokeString"", [ url ]); + "); + + var client = new HttpClient (); + Assert.StartsWith ("blob:", HelperMarshal._stringResource); + Console.WriteLine(HelperMarshal._stringResource); + HttpRequestMessage rm = new HttpRequestMessage(HttpMethod.Get, new Uri (HelperMarshal._stringResource)); + HttpResponseMessage resp = await client.SendAsync (rm); + Assert.NotNull (resp.Content); + string content = await resp.Content.ReadAsStringAsync(); + } + [Fact] public void BlobStringUri_Marshal_CorrectValues() { diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/TypedArrayTests.cs b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/TypedArrayTests.cs index 14b31faea0d29..e7e1d02a4ec5e 100644 --- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/TypedArrayTests.cs +++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/TypedArrayTests.cs @@ -26,6 +26,19 @@ public static void Uint8ClampedArrayFrom(Function objectPrototype) Assert.True(from.Length == 50); Assert.Equal("[object Uint8ClampedArray]", objectPrototype.Call(from)); } + + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Uint8ClampedArrayFrom_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetUint8ClampedArray"", [ obj, 50 ]); + App.call_test_method ( ""GetUint8ClampedArray"", [ obj ]); + "); + Assert.True(HelperMarshal._caUInt.Length == 50); + Assert.Equal("[object Uint8ClampedArray]", objectPrototype.Call(HelperMarshal._caUInt)); + } [Theory] [MemberData(nameof(Object_Prototype))] @@ -37,6 +50,19 @@ public static void Uint8ArrayFrom(Function objectPrototype) Assert.Equal("[object Uint8Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Uint8ArrayFrom_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetUint8Array"", [ obj, 50 ]); + App.call_test_method ( ""GetUint8Array"", [ obj ]); + "); + Assert.True(HelperMarshal._uint8Array.Length == 50); + Assert.Equal("[object Uint8Array]", objectPrototype.Call(HelperMarshal._uint8Array)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Uint16ArrayFrom(Function objectPrototype) @@ -47,6 +73,20 @@ public static void Uint16ArrayFrom(Function objectPrototype) Assert.Equal("[object Uint16Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Uint16ArrayFrom_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetUint16Array"", [ obj, 50 ]); + App.call_test_method ( ""GetUint16Array"", [ obj ]); + "); + var array = HelperMarshal._uint16Array; + Assert.True(array.Length == 50); + Assert.Equal("[object Uint16Array]", objectPrototype.Call(array)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Uint32ArrayFrom(Function objectPrototype) @@ -57,6 +97,19 @@ public static void Uint32ArrayFrom(Function objectPrototype) Assert.Equal("[object Uint32Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Uint32ArrayFrom_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetUint32Array"", [ obj, 50 ]); + App.call_test_method ( ""GetUint32Array"", [ obj ]); + "); + Assert.True(HelperMarshal._uint32Array.Length == 50); + Assert.Equal("[object Uint32Array]", objectPrototype.Call(HelperMarshal._uint32Array)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Int8ArrayFrom(Function objectPrototype) @@ -67,6 +120,19 @@ public static void Int8ArrayFrom(Function objectPrototype) Assert.Equal("[object Int8Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Int8ArrayFrom_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetInt8Array"", [ obj, 50 ]); + App.call_test_method ( ""GetInt8Array"", [ obj ]); + "); + Assert.True(HelperMarshal._int8Array.Length == 50); + Assert.Equal("[object Int8Array]", objectPrototype.Call(HelperMarshal._int8Array)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Int16ArrayFrom(Function objectPrototype) @@ -77,6 +143,19 @@ public static void Int16ArrayFrom(Function objectPrototype) Assert.Equal("[object Int16Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Int16ArrayFrom_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetInt16Array"", [ obj, 50 ]); + App.call_test_method ( ""GetInt16Array"", [ obj ]); + "); + Assert.True(HelperMarshal._int16Array.Length == 50); + Assert.Equal("[object Int16Array]", objectPrototype.Call(HelperMarshal._int16Array)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Int32ArrayFrom(Function objectPrototype) @@ -87,6 +166,19 @@ public static void Int32ArrayFrom(Function objectPrototype) Assert.Equal("[object Int32Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Int32ArrayFrom_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetInt32Array"", [ obj, 50 ]); + App.call_test_method ( ""GetInt32Array"", [ obj ]); + "); + Assert.True(HelperMarshal._int32Array.Length == 50); + Assert.Equal("[object Int32Array]", objectPrototype.Call(HelperMarshal._int32Array)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Float32ArrayFrom(Function objectPrototype) @@ -97,6 +189,19 @@ public static void Float32ArrayFrom(Function objectPrototype) Assert.Equal("[object Float32Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Float32ArrayFrom_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetFloat32Array"", [ obj, 50 ]); + App.call_test_method ( ""GetFloat32Array"", [ obj ]); + "); + Assert.True(HelperMarshal._float32Array.Length == 50); + Assert.Equal("[object Float32Array]", objectPrototype.Call(HelperMarshal._float32Array)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Float64ArrayFrom(Function objectPrototype) @@ -107,6 +212,19 @@ public static void Float64ArrayFrom(Function objectPrototype) Assert.Equal("[object Float64Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Float64ArrayFrom_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetFloat64Array"", [ obj, 50 ]); + App.call_test_method ( ""GetFloat64Array"", [ obj ]); + "); + Assert.True(HelperMarshal._float64Array.Length == 50); + Assert.Equal("[object Float64Array]", objectPrototype.Call(HelperMarshal._float64Array)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Uint8ClampedArrayFromSharedArrayBuffer(Function objectPrototype) @@ -116,6 +234,19 @@ public static void Uint8ClampedArrayFromSharedArrayBuffer(Function objectPrototy Assert.Equal("[object Uint8ClampedArray]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Uint8ClampedArrayFromSharedArrayBuffer_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetUint8ClampedArrayFromSharedArrayBuffer"", [ obj, 50 ]); + App.call_test_method ( ""GetUint8ClampedArrayFromSharedArrayBuffer"", [ obj ]); + "); + Assert.True(HelperMarshal._caFromSharedArrayBuffer.Length == 50); + Assert.Equal("[object Uint8ClampedArray]", objectPrototype.Call(HelperMarshal._caFromSharedArrayBuffer)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Uint8ArrayFromSharedArrayBuffer(Function objectPrototype) @@ -125,6 +256,19 @@ public static void Uint8ArrayFromSharedArrayBuffer(Function objectPrototype) Assert.Equal("[object Uint8Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Uint8ArrayFromSharedArrayBuffer_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetUint8ArrayFromSharedArrayBuffer"", [ obj, 50 ]); + App.call_test_method ( ""GetUint8ArrayFromSharedArrayBuffer"", [ obj ]); + "); + Assert.True(HelperMarshal._uint8FromSharedArrayBuffer.Length == 50); + Assert.Equal("[object Uint8Array]", objectPrototype.Call(HelperMarshal._uint8FromSharedArrayBuffer)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Uint16ArrayFromSharedArrayBuffer(Function objectPrototype) @@ -134,6 +278,19 @@ public static void Uint16ArrayFromSharedArrayBuffer(Function objectPrototype) Assert.Equal("[object Uint16Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Uint16ArrayFromSharedArrayBuffer_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetUint16ArrayFromSharedArrayBuffer"", [ obj, 50 ]); + App.call_test_method ( ""GetUint16ArrayFromSharedArrayBuffer"", [ obj ]); + "); + Assert.True(HelperMarshal._uint16FromSharedArrayBuffer.Length == 25); + Assert.Equal("[object Uint16Array]", objectPrototype.Call(HelperMarshal._uint16FromSharedArrayBuffer)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Uint32ArrayFromSharedArrayBuffer(Function objectPrototype) @@ -143,6 +300,19 @@ public static void Uint32ArrayFromSharedArrayBuffer(Function objectPrototype) Assert.Equal("[object Uint32Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Uint32ArrayFromSharedArrayBuffer_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetUint32ArrayFromSharedArrayBuffer"", [ obj, 40 ]); + App.call_test_method ( ""GetUint32ArrayFromSharedArrayBuffer"", [ obj ]); + "); + Assert.True(HelperMarshal._uint32FromSharedArrayBuffer.Length == 10); + Assert.Equal("[object Uint32Array]", objectPrototype.Call(HelperMarshal._uint32FromSharedArrayBuffer)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Int8ArrayFromSharedArrayBuffer(Function objectPrototype) @@ -152,6 +322,19 @@ public static void Int8ArrayFromSharedArrayBuffer(Function objectPrototype) Assert.Equal("[object Int8Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Int8ArrayFromSharedArrayBuffer_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetInt8ArrayFromSharedArrayBuffer"", [ obj, 50 ]); + App.call_test_method ( ""GetInt8ArrayFromSharedArrayBuffer"", [ obj ]); + "); + Assert.True(HelperMarshal._int8fromSharedArrayBuffer.Length == 50); + Assert.Equal("[object Int8Array]", objectPrototype.Call(HelperMarshal._int8fromSharedArrayBuffer)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Int16ArrayFromSharedArrayBuffer(Function objectPrototype) @@ -161,6 +344,19 @@ public static void Int16ArrayFromSharedArrayBuffer(Function objectPrototype) Assert.Equal("[object Int16Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Int16ArrayFromSharedArrayBuffer_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetInt16ArrayFromSharedArrayBuffer"", [ obj, 50 ]); + App.call_test_method ( ""GetInt16ArrayFromSharedArrayBuffer"", [ obj ]); + "); + Assert.True(HelperMarshal._int16fromSharedArrayBuffer.Length == 25); + Assert.Equal("[object Int16Array]", objectPrototype.Call(HelperMarshal._int16fromSharedArrayBuffer)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Int32ArrayFromSharedArrayBuffer(Function objectPrototype) @@ -170,6 +366,19 @@ public static void Int32ArrayFromSharedArrayBuffer(Function objectPrototype) Assert.Equal("[object Int32Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Int32ArrayFromSharedArrayBuffer_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetInt32ArrayFromSharedArrayBuffer"", [ obj, 40 ]); + App.call_test_method ( ""GetInt32ArrayFromSharedArrayBuffer"", [ obj ]); + "); + Assert.True(HelperMarshal._int32fromSharedArrayBuffer.Length == 10); + Assert.Equal("[object Int32Array]", objectPrototype.Call(HelperMarshal._int32fromSharedArrayBuffer)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Float32ArrayFromSharedArrayBuffer(Function objectPrototype) @@ -179,6 +388,19 @@ public static void Float32ArrayFromSharedArrayBuffer(Function objectPrototype) Assert.Equal("[object Float32Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Float32ArrayFromSharedArrayBuffer_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetFloat32ArrayFromSharedArrayBuffer"", [ obj, 40 ]); + App.call_test_method ( ""GetFloat32ArrayFromSharedArrayBuffer"", [ obj ]); + "); + Assert.True(HelperMarshal._float32fromSharedArrayBuffer.Length == 10); + Assert.Equal("[object Float32Array]", objectPrototype.Call(HelperMarshal._float32fromSharedArrayBuffer)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Float64ArrayFromSharedArrayBuffer(Function objectPrototype) @@ -188,6 +410,19 @@ public static void Float64ArrayFromSharedArrayBuffer(Function objectPrototype) Assert.Equal("[object Float64Array]", objectPrototype.Call(from)); } + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupported))] + [MemberData(nameof(Object_Prototype))] + public static void Float64ArrayFromSharedArrayBuffer_Browser(Function objectPrototype) + { + Runtime.InvokeJS(@" + var obj = { }; + App.call_test_method ( ""SetFloat64ArrayFromSharedArrayBuffer"", [ obj, 40 ]); + App.call_test_method ( ""GetFloat64ArrayFromSharedArrayBuffer"", [ obj ]); + "); + Assert.True(HelperMarshal._float64fromSharedArrayBuffer.Length == 5); + Assert.Equal("[object Float64Array]", objectPrototype.Call(HelperMarshal._float64fromSharedArrayBuffer)); + } + [Theory] [MemberData(nameof(Object_Prototype))] public static void Uint8ClampedArrayFromArrayBuffer(Function objectPrototype)