diff --git a/Jint.Tests/Runtime/Domain/TextDecoder.cs b/Jint.Tests/Runtime/Domain/TextDecoder.cs
new file mode 100644
index 0000000000..2e418cc01c
--- /dev/null
+++ b/Jint.Tests/Runtime/Domain/TextDecoder.cs
@@ -0,0 +1,15 @@
+using System.Text;
+
+namespace Jint.Tests.Runtime.Domain;
+
+///
+/// https://encoding.spec.whatwg.org/#textdecoder
+///
+/// Public API, do not make internal!
+public sealed class TextDecoder
+{
+ public string Decode() => string.Empty;
+
+
+ public string Decode(byte[] buff) => Encoding.UTF8.GetString(buff);
+}
diff --git a/Jint.Tests/Runtime/JsValueConversionTests.cs b/Jint.Tests/Runtime/JsValueConversionTests.cs
index 3668e9b15b..b6c991b90d 100644
--- a/Jint.Tests/Runtime/JsValueConversionTests.cs
+++ b/Jint.Tests/Runtime/JsValueConversionTests.cs
@@ -1,4 +1,5 @@
using Jint.Native;
+using Jint.Runtime;
namespace Jint.Tests.Runtime
{
@@ -164,5 +165,38 @@ public void ShouldBeUndefined()
Assert.Equal(false, value.IsString());
Assert.Equal(true, value.IsUndefined());
}
+
+ [Fact]
+ public void ShouldConvertArrayBuffer()
+ {
+ var value = _engine.Evaluate("new Uint8Array([102, 111, 111]).buffer");
+ Assert.Equal(true, value.IsArrayBuffer());
+ Assert.Equal([102, 111, 111], value.AsArrayBuffer());
+ Assert.Equal([102, 111, 111], value.ToObject() as byte[]);
+
+ (value as JsArrayBuffer).DetachArrayBuffer();
+
+ Assert.Equal(true, value.IsArrayBuffer());
+ Assert.Equal(null, value.AsArrayBuffer());
+ Assert.Throws(value.ToObject);
+ Assert.Throws(JsValue.Undefined.AsArrayBuffer);
+ }
+
+ [Fact]
+ public void ShouldConvertDataView()
+ {
+ var value = _engine.Evaluate("new DataView(new Uint8Array([102, 102, 111, 111, 111]).buffer, 1, 3)");
+
+ Assert.Equal(true, value.IsDataView());
+ Assert.Equal([102, 111, 111], value.AsDataView());
+ Assert.Equal([102, 111, 111], value.ToObject() as byte[]);
+
+ (value as JsDataView)._viewedArrayBuffer.DetachArrayBuffer();
+
+ Assert.Equal(true, value.IsDataView());
+ Assert.Equal(null, value.AsDataView());
+ Assert.Throws(value.ToObject);
+ Assert.Throws(JsValue.Undefined.AsDataView);
+ }
}
}
diff --git a/Jint.Tests/Runtime/TextTests.cs b/Jint.Tests/Runtime/TextTests.cs
new file mode 100644
index 0000000000..8be9d53199
--- /dev/null
+++ b/Jint.Tests/Runtime/TextTests.cs
@@ -0,0 +1,33 @@
+using Jint.Runtime.Interop;
+using Jint.Tests.Runtime.Domain;
+
+namespace Jint.Tests.Runtime;
+
+public sealed class TextTests
+{
+ private readonly Engine _engine;
+
+ public TextTests()
+ {
+ _engine = new Engine()
+ .SetValue("log", new Action