tor-browser

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

webtransport-h3.https.sub.any.js (912B)


      1 // META: global=window,worker
      2 // META: script=/common/get-host-info.sub.js
      3 
      4 const HOST = get_host_info().ORIGINAL_HOST;
      5 const PORT = '{{ports[webtransport-h3][0]}}';
      6 const BASE = `https://${HOST}:${PORT}`;
      7 
      8 promise_test(async t => {
      9    const wt = new WebTransport(`${BASE}/webtransport/handlers/echo.py`);
     10    // When a connection fails `closed` attribute will be rejected.
     11    wt.closed.catch((error) => {
     12        t.unreached_func(`The 'closed' attribute should not be rejected: ${error}`);
     13    });
     14    await wt.ready;
     15 
     16    const stream = await wt.createBidirectionalStream();
     17 
     18    const writer = stream.writable.getWriter();
     19    await writer.write(new Uint8Array([42]));
     20    writer.releaseLock();
     21 
     22    const reader = stream.readable.getReader();
     23    const { value } = await reader.read();
     24 
     25    assert_equals(value[0], 42);
     26 }, "WebTransport server should be running and should handle a bidirectional stream");