blob: 7a2a6e05c4417fe49b1f283f8cec36e7e809ba29 (
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
|
%(import)s
if ('DedicatedWorkerGlobalScope' in self &&
self instanceof DedicatedWorkerGlobalScope) {
self.onmessage = event => onMessageFromParent(event, self);
} else if ('SharedWorkerGlobalScope' in self &&
self instanceof SharedWorkerGlobalScope) {
onconnect = event => {
const port = event.ports[0];
port.onmessage = event => onMessageFromParent(event, port);
};
}
// Receive a message from the parent and start the test.
function onMessageFromParent(event, port) {
const configurationError = "%(error)s";
if (configurationError.length > 0) {
port.postMessage({error: configurationError});
return;
}
invokeRequest(event.data.subresource,
event.data.sourceContextList)
.then(result => port.postMessage(result))
.catch(e => {
const message = (e.error && e.error.stack) || e.message || "Error";
port.postMessage({error: message});
});
}
|