Bug 1530812 [wpt PR 15495] - Add signed exchange reporting error test cases, a=testonly
[gecko.git] / testing / web-platform / tests / signed-exchange / reporting / sxg-reporting-prefetch-failed-zero-success-feaction.tentative.html
blobb0f7103053ba8e8ae938be3831de9b785d78047c
1 <!DOCTYPE html>
2 <title>SXG reporting test of sxg.failed for prefetch (zero success fraction)</title>
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <script src="/common/get-host-info.sub.js"></script>
6 <script src="/network-error-logging/support/nel.sub.js"></script>
7 <script src="../resources/sxg-util.js"></script>
8 <body>
9 <script>
10 const alt_origin = get_host_info().HTTPS_NOTSAMESITE_ORIGIN;
11 const test_origin = get_host_info().HTTPS_ORIGIN;
13 nel_test(async t => {
14 await fetchResourceWithZeroSuccessFractionPolicy();
15 const sxg_url =
16 alt_origin + '/signed-exchange/resources/sxg/sxg-cert-not-found.sxg?prefetch';
17 const cert_url =
18 test_origin + '/signed-exchange/resources/not_found_certfile.cbor';
19 addPrefetch(sxg_url);
20 assert_true(await reportExists(
22 url: sxg_url,
23 user_agent: navigator.userAgent,
24 type: "network-error",
25 body: {
26 phase: "sxg",
27 // The origin of this SXG's certURL is different from the reporting
28 // origin. So the report must be downgraded.
29 type: "sxg.failed",
30 elapsed_time: 0,
31 status_code: 200,
32 referrer: location.href,
33 sxg: {
34 outer_url: sxg_url,
35 inner_url:
36 innerURLOrigin() + '/signed-exchange/resources/inner-url.html',
37 cert_url: [cert_url]
40 metadata: {
41 content_type: "application/reports+json",
44 ), 'SXG error reporting must be downgraded when the cert URL is different ' +
45 'from the reporting origin');
46 assert_false(await reportExists(
48 url: sxg_url,
49 user_agent: navigator.userAgent,
50 type: "network-error",
51 body: {
52 phase: "application",
53 type: "ok",
54 status_code: 200,
55 referrer: location.href,
57 metadata: {
58 content_type: "application/reports+json",
61 ), 'Succeeded normal NEL report should not be sent when success fraction ' +
62 'is zero.');
63 }, 'SXG error report must be downgraded when the cert URL is different from ' +
64 'the reporting origin. And succeeded normal NEL report should not be sent ' +
65 ' when success fraction is zero.');
66 </script>
67 </body>