mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.12k stars 848 forks source link

Implement `$262.detachArrayBuffer` for typed arrays #1527

Open andreabergia opened 1 month ago

andreabergia commented 1 month ago

Quite a few test cases for typed arrays fail because rhino lacks $262.detachArrayBuffer, which should be a implementation-defined way to detach an Array Buffer. For example, prototype/copyWithin/coerced-values-end-detached.js.

p-bakker commented 1 month ago

This should implement this operation based on this documentation

p-bakker commented 1 month ago

Based on just looking at the NativeArrayBuffer it seems to me that is not just the test facility is missing, but that NativeArrayBuffer lacks the facilities to 'detach' as well

Could maybe be as straightforward as setting the internal (byte) buffer to null and adding some checks and throws