summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webrtc-encoded-transform/script-write-twice-transform-worker.js
blob: 5d428c81b3aa5434319e10fbec6a0075a7d40b98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
onrtctransform = (event) => {
    const transformer = event.transformer;

    self.postMessage("started");

    transformer.reader = transformer.readable.getReader();
    transformer.writer = transformer.writable.getWriter();
    function process(transformer)
    {
        transformer.reader.read().then(chunk => {
            if (chunk.done)
                return;

            transformer.writer.write(chunk.value);
            transformer.writer.write(chunk.value);
            process(transformer);
        });
    }

    process(transformer);
};
self.postMessage("registered");