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-navigation-cert_fetch_error-downgraded.tentative.html
blob845b7e01ff28b92f4db7919a3f29661ee78df544
1 <!DOCTYPE html>
2 <title>SXG reporting test of sxg.failed downgraded from sxg.cert_fetch_error for navigation</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 fetchResourceWithBasicPolicy();
15 const sxg_url =
16 alt_origin + '/signed-exchange/resources/sxg/sxg-cert-not-found.sxg?navigation';
17 const cert_url = test_origin + '/signed-exchange/resources/not_found_certfile.cbor';
18 const message = await openSXGInIframeAndWaitForMessage(t, sxg_url);
19 assert_equals(message.location,
20 innerURLOrigin() + '/signed-exchange/resources/inner-url.html');
21 assert_true(message.is_fallback);
22 assert_true(await reportsExist([
24 url: sxg_url,
25 user_agent: navigator.userAgent,
26 type: "network-error",
27 body: {
28 phase: "sxg",
29 // The origin of this SXG's certURL is different from the reporting
30 // origin. So the report must be downgraded.
31 type: "sxg.failed",
32 elapsed_time: 0,
33 status_code: 200,
34 referrer: location.href,
35 sxg: {
36 outer_url: sxg_url,
37 inner_url:
38 innerURLOrigin() + '/signed-exchange/resources/inner-url.html',
39 cert_url: [cert_url]
42 metadata: {
43 content_type: "application/reports+json",
47 url: sxg_url,
48 user_agent: navigator.userAgent,
49 type: "network-error",
50 body: {
51 phase: "application",
52 type: "ok",
53 status_code: 200,
54 referrer: location.href,
56 metadata: {
57 content_type: "application/reports+json",
60 ]));
61 }, 'SXG reporting test of sxg.failed downgraded from sxg.cert_fetch_error for' +
62 ' navigation.');
63 </script>
64 </body>