summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/ArrayBuffer/CloneArrayBuffer.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/ArrayBuffer/CloneArrayBuffer.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/ArrayBuffer/CloneArrayBuffer.js')
-rw-r--r--js/src/tests/non262/ArrayBuffer/CloneArrayBuffer.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/js/src/tests/non262/ArrayBuffer/CloneArrayBuffer.js b/js/src/tests/non262/ArrayBuffer/CloneArrayBuffer.js
new file mode 100644
index 0000000000..480314ad8e
--- /dev/null
+++ b/js/src/tests/non262/ArrayBuffer/CloneArrayBuffer.js
@@ -0,0 +1,35 @@
+var BUGNUMBER = 1264941;
+var summary = 'CloneArrayBuffer should be called with byteLength of source typedArray';
+
+print(BUGNUMBER + ": " + summary);
+
+function test(ctor, byteLength) {
+ var abuf = new ctor(byteLength);
+ assertEq(abuf.byteLength, byteLength);
+
+ for (var byteOffset of [0, 16]) {
+ for (var elementLength = 0;
+ elementLength < (byteLength - byteOffset) / Float64Array.BYTES_PER_ELEMENT;
+ elementLength++) {
+ var a1 = new Float64Array(abuf, byteOffset, elementLength);
+ assertEq(a1.buffer.byteLength, byteLength);
+ assertEq(a1.byteLength, elementLength * Float64Array.BYTES_PER_ELEMENT);
+ assertEq(a1.byteOffset, byteOffset);
+
+ var a2 = new Float64Array(a1);
+ assertEq(a2.buffer.byteLength, a1.byteLength);
+ assertEq(a2.byteLength, a1.byteLength);
+ assertEq(a2.byteOffset, 0);
+ }
+ }
+}
+
+test(ArrayBuffer, 16);
+test(ArrayBuffer, 128);
+
+class MyArrayBuffer extends ArrayBuffer {}
+test(MyArrayBuffer, 16);
+test(MyArrayBuffer, 128);
+
+if (typeof reportCompare === 'function')
+ reportCompare(true, true);