Bug 1623931 [wpt PR 22360] - Fix flaky cache-storage-reporting.https.html, a=testonly
[gecko.git] / testing / web-platform / tests / html / cross-origin-embedder-policy / cache-storage-reporting-dedicated-worker.https.html
blob468861a9df60fc790e10515d3d01fd9fbd818266
1 <!doctype html>
2 <html>
3 <head>
4 <title>
5 Check COEP report are send for CacheStorage requests in DedicatedWorker
6 </title>
7 <script src="/resources/testharness.js"></script>
8 <script src="/resources/testharnessreport.js"></script>
9 <script src="/common/get-host-info.sub.js"></script>
10 <script src="/common/utils.js"></script>
11 <script src="/service-workers/service-worker/resources/test-helpers.sub.js">
12 </script>
13 <script src="./resources/cache-storage-reporting.js"> </script>
14 </head>
15 <script>
17 promise_test(async (t) => {
18 const worker_url = local(encode(worker_path));
19 const iframe_url =
20 local(encode(iframe_path + header_coep + header_report_to));
21 dedicated_worker_script = `
22 (async function() {
23 const w = new Worker('${worker_url}');
24 w.postMessage(\`${eval_script}\`);
25 })();
27 const iframe = await makeIframe(t, iframe_url);
28 iframe.contentWindow.postMessage(dedicated_worker_script);
29 const report = await fetchReport();
30 assert_equals(report["body"]["blocked-url"], image_url.toString());
31 assert_equals(report["body"]["type"], "corp");
32 assert_equals(report["type"], "coep");
33 assert_equals(normalize(report["url"]), normalize(worker_url.toString()));
34 }, "COEP support on DedicatedWorker.")
36 promise_test(async (t) => {
37 const worker_url = local(encode(worker_path));
38 const iframe_url =
39 local(encode(iframe_path + header_coep_report_only + header_report_to));
40 dedicated_worker_script = `
41 (async function() {
42 const w = new Worker('${worker_url}');
43 w.postMessage(\`${eval_script}\`);
44 })();
46 const iframe = await makeIframe(t, iframe_url);
47 iframe.contentWindow.postMessage(dedicated_worker_script);
48 const report = await fetchReport();
49 assert_equals(report["body"]["blocked-url"], image_url.toString());
50 assert_equals(report["body"]["type"], "corp");
51 assert_equals(report["type"], "coep");
52 assert_equals(normalize(report["url"]), normalize(worker_url.toString()));
53 }, "COEP-Report-Only support on DedicatedWorker.")
55 </script>
56 </html>