blob: af76b6c11b4ed103b8fdfe5ca206f22fe686a78f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
'use strict';
importScripts('/resources/testharness.js', 'helpers.js');
onmessage = msg => {
const client = msg.source;
if (msg.data === 'SEND') {
sendingTest(client);
} else {
receivingTest(msg, client);
}
};
function sendingTest(client) {
const orig = createOriginalReadableStream();
try {
client.postMessage(orig, [orig]);
} catch (e) {
client.postMessage(e.message);
}
}
function receivingTest(msg, client) {
try {
msg.waitUntil(testMessage(msg)
.then(() => client.postMessage('OK'))
.catch(e => client.postMessage(`BAD: ${e}`)));
} catch (e) {
client.postMessage(`BAD: ${e}`);
}
}
|