tor-browser

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

response-stream-bad-chunk.any.js (1208B)


      1 // META: global=window,worker
      2 // META: title=Response causes TypeError from bad chunk type
      3 
      4 function runChunkTest(responseReaderMethod, testDescription) {
      5  promise_test(test => {
      6    let stream = new ReadableStream({
      7      start(controller) {
      8        controller.enqueue("not Uint8Array");
      9        controller.close();
     10      }
     11    });
     12 
     13    return promise_rejects_js(test, TypeError,
     14      new Response(stream)[responseReaderMethod](),
     15      'TypeError should propagate'
     16    )
     17  }, testDescription)
     18 }
     19 
     20 runChunkTest('arrayBuffer', 'ReadableStream with non-Uint8Array chunk passed to Response.arrayBuffer() causes TypeError');
     21 runChunkTest('blob',        'ReadableStream with non-Uint8Array chunk passed to Response.blob() causes TypeError');
     22 runChunkTest('bytes',       'ReadableStream with non-Uint8Array chunk passed to Response.bytes() causes TypeError');
     23 runChunkTest('formData',    'ReadableStream with non-Uint8Array chunk passed to Response.formData() causes TypeError');
     24 runChunkTest('json',        'ReadableStream with non-Uint8Array chunk passed to Response.json() causes TypeError');
     25 runChunkTest('text',        'ReadableStream with non-Uint8Array chunk passed to Response.text() causes TypeError');