tor-browser

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

RTCDataChannel-send-blob-order.html (1036B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>RTCDataChannel.prototype.send for blobs</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="RTCPeerConnection-helper.js"></script>
      7 <script>
      8 
      9 for (const options of [{}, {negotiated: true, id: 0}]) {
     10  const mode = `${options.negotiated? "Negotiated d" : "D"}atachannel`;
     11 
     12  promise_test(async t => {
     13    const data1 = new Blob(['blob']);
     14    const data1Size = data1.size;
     15    const data2 = new ArrayBuffer(8);
     16    const data2Size = data2.byteLength;
     17 
     18    const [channel1, channel2] = await createDataChannelPair(t, options);
     19    channel2.binaryType = "arraybuffer";
     20 
     21    channel1.send(data1);
     22    channel1.send(data2);
     23 
     24    let e = await new Promise(r => channel2.onmessage = r);
     25    assert_equals(e.data.byteLength, data1Size);
     26 
     27    e = await new Promise(r => channel2.onmessage = r);
     28    assert_equals(e.data.byteLength, data2Size);
     29  }, `${mode} should send data following the order of the send call`);
     30 }
     31 </script>