summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/cross-origin-embedder-policy/require-corp-worker-script-revalidation.html
blob: 74794967fb1ce72b494a48b80634151e045d25f2 (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
<!doctype html>
<title>COEP and dedicated worker</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/worker-support.js"></script>
<body>
<script>

promise_test(async (t) => {
  const worker1 = new Worker("/html/cross-origin-embedder-policy/resources/dedicated-worker-supporting-revalidation.py");
  worker1.onerror = t.unreached_func('Worker.onerror should not be called for first worker');
  worker1.postMessage("foo");
  const result1 = await waitForMessage(worker1);
  assert_equals(result1.data, 'LOADED');

  // Load the worker a second time, which should trigger revalidation of the cached resource.
  const worker2 = new Worker("/html/cross-origin-embedder-policy/resources/dedicated-worker-supporting-revalidation.py");
  worker2.onerror = t.unreached_func('Worker.onerror should not be called worker second worker');
  worker2.postMessage("foo");
  const result2 = await waitForMessage(worker2);
  assert_equals(result2.data, 'LOADED');
}, 'COEP: require-corp with revalidated worker script');
</script>
</body>