summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/resources/worker_with_images.js
blob: 1fa4893201ee006431a58d7a96a50b82e6ab6f30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
let numComplete = 0;

function checkDone() {
  ++numComplete;
  if (numComplete == 2) {
    const numEntries = performance.getEntries().length;
    postMessage(numEntries);
  }
}

function makeRequest(request) {
  var xhr = new XMLHttpRequest;
  xhr.open('get', request, true);
  xhr.onreadystatechange = function() {
    if (xhr.readyState == 4) {
      checkDone();
    }
  }
  xhr.send();
}
makeRequest('blue.png');
makeRequest('resource_timing_test0.png');