summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mediacapture-insertable-streams/MediaStreamTrackProcessor-worker.js
blob: 51eaef80a90a6e24fce8cad4fee03e05548e4517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
onmessage = async msg => {
  const reader = msg.data.readable.getReader();
  let readResult = await reader.read();
  postMessage(readResult.value);
  readResult.value.close();
  // Continue reading until the stream is done due to a track.stop()
  while (true) {
    readResult = await reader.read();
    if (readResult.done) {
      break;
    } else {
      readResult.value.close();
    }
  }
  await reader.closed;
  postMessage('closed');
}