tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

send-data-sharedarraybuffer.any.js (1144B)


      1 // META: title=XMLHttpRequest.send(sharedarraybuffer)
      2 
      3 test(() => {
      4    const xhr = new XMLHttpRequest();
      5    // See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
      6    const buf = new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer;
      7 
      8    xhr.open("POST", "./resources/content.py", true);
      9    assert_throws_js(TypeError, function() {
     10        xhr.send(buf)
     11    });
     12 }, "sending a SharedArrayBuffer");
     13 
     14 ["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array",
     15 "Int32Array", "Uint32Array", "BigInt64Array", "BigUint64Array",
     16 "Float16Array", "Float32Array", "Float64Array", "DataView"].forEach((type) => {
     17    test(() => {
     18        const xhr = new XMLHttpRequest();
     19        // See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
     20        const arr = new self[type](new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer);
     21 
     22        xhr.open("POST", "./resources/content.py", true);
     23        assert_throws_js(TypeError, function() {
     24            xhr.send(arr)
     25        });
     26    }, `sending a ${type} backed by a SharedArrayBuffer`);
     27 });