Move non-upstreamed Resource Timing tests out of web-platform-tests
[WebKit-https.git] / LayoutTests / http / wpt / resource-timing / resources / rt-worker-resources.js
1 importScripts("rt-utilities.sub.js");
2
3 addEventListener("message", function(event) {
4     if (!hasNecessaryPerformanceFeatures()) {
5         postMessage("error");
6         return;
7     }
8
9     performance.clearResourceTimings();
10
11     let promises = [];
12
13     if (event.data.n)
14         promises.push(loadResources(event.data.n));
15     if (event.data.sharedResourceURL);
16         promises.push(fetch(event.data.sharedResourceURL));
17
18     Promise.all(promises).then(function() {
19         let entries = performance.getEntriesByType("resource");
20         let serializedEntries = JSON.parse(JSON.stringify(entries));
21         postMessage(serializedEntries);
22     });
23 });