1
0
Fork 0
firefox/testing/web-platform/tests/xhr/send-data-sharedarraybuffer.any.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

27 lines
1.1 KiB
JavaScript

// META: title=XMLHttpRequest.send(sharedarraybuffer)
test(() => {
const xhr = new XMLHttpRequest();
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
const buf = new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer;
xhr.open("POST", "./resources/content.py", true);
assert_throws_js(TypeError, function() {
xhr.send(buf)
});
}, "sending a SharedArrayBuffer");
["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array",
"Int32Array", "Uint32Array", "BigInt64Array", "BigUint64Array",
"Float16Array", "Float32Array", "Float64Array", "DataView"].forEach((type) => {
test(() => {
const xhr = new XMLHttpRequest();
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
const arr = new self[type](new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer);
xhr.open("POST", "./resources/content.py", true);
assert_throws_js(TypeError, function() {
xhr.send(arr)
});
}, `sending a ${type} backed by a SharedArrayBuffer`);
});