summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/workers/worker-request-animation-frame.html
blob: 2d65bc2c4610eb91a88c46afd48875355a3638f8 (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
<!DOCTYPE html>
<html>
<head>
<title>raf time in dedicated workers</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
  async function waitForMessage(worker) {
    return new Promise(resolve => {
      worker.onmessage = event => resolve(event);
    });
  }

  promise_test(t => {
    const worker = new Worker('support/worker-request-animation-frame.js');
    const message = waitForMessage(worker);
    worker.postMessage('');
    message.then((event) => {
      const raf_time = event.data;
      assert_true(performance.now() >= raf_time,
                  'raf time cannot exceed time of page load');
    });
    return message;
  }, 'requestAnimationTime reports frame time relative to worker load');
</script>