summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/send-data-sharedarraybuffer.any.js
blob: a87160c56b1dc5365aa76f4e6e63eef6ce7aa8ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// 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`);
});