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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
<!DOCTYPE html>
<title>Subresource signed exchange prefetch.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/network-error-logging/support/nel.sub.js"></script>
<script src="../resources/sxg-util.js"></script>
<body>
<script>
nel_iframe_test(async t => {
const alt_origin = get_host_info().HTTPS_NOTSAMESITE_ORIGIN;
const test_origin = get_host_info().HTTPS_ORIGIN;
await loadResourceWithBasicPolicyInIframe();
const iframe_path =
alt_origin +
'/signed-exchange/resources/sxg-subresource-mismatch-iframe.html';
const wait_message = (new Promise((resolve) => {
const on_message = (event) => {
window.removeEventListener('message', on_message);
resolve(event.data);
};
window.addEventListener('message', on_message);
}));
withIframe(iframe_path);
const message = await wait_message;
assert_equals(message, 'from server');
const cert_url = test_origin + '/signed-exchange/resources/127.0.0.1.sxg.pem.cbor';
const main_outer_url = alt_origin + '/signed-exchange/resources/sxg/sxg-subresource-header-integrity-mismatch.sxg';
const main_inner_url = innerURLOrigin() + '/signed-exchange/resources/sxg-subresource-sxg.html';
const sub_outer_url = alt_origin + '/signed-exchange/resources/sxg/sxg-subresource-script.sxg';
const sub_inner_url = innerURLOrigin() + '/signed-exchange/resources/sxg-subresource-script.js';
const iframe_url = alt_origin + '/signed-exchange/resources/sxg-subresource-mismatch-iframe.html';
assert_true(await reportsExist([
// Normal NEL report for the iframe's HTML.
{
url: iframe_url,
user_agent: navigator.userAgent,
type: "network-error",
body: {
phase: "application",
type: "ok",
status_code: 200,
referrer: location.origin + '/',
},
metadata: {
content_type: "application/reports+json",
},
},
// Normal NEL report for the main resource signed exchange.
{
url: main_outer_url,
user_agent: navigator.userAgent,
type: "network-error",
body: {
phase: "application",
type: "ok",
status_code: 200,
referrer: iframe_url,
},
metadata: {
content_type: "application/reports+json",
},
},
// Signed Exchange NEL report for the main resource signed exchange.
{
url: main_outer_url,
user_agent: navigator.userAgent,
type: "network-error",
body: {
phase: "sxg",
type: "ok",
status_code: 200,
referrer: iframe_url,
sxg: {
outer_url: main_outer_url,
inner_url: main_inner_url,
cert_url: [cert_url]
}
},
metadata: {
content_type: "application/reports+json",
},
},
// Signed Exchange NEL report for the subresource signed exchange header
// integrity mismatch.
{
url: sub_outer_url,
user_agent: navigator.userAgent,
type: "network-error",
body: {
phase: "sxg",
type: "sxg.header_integrity_mismatch",
status_code: 200,
referrer: main_outer_url,
sxg: {
outer_url: sub_outer_url,
inner_url: sub_inner_url,
cert_url: [cert_url]
}
},
metadata: {
content_type: "application/reports+json",
},
},
// Normal NEL report for the main resource signed exchange.
{
url: sub_outer_url,
user_agent: navigator.userAgent,
type: "network-error",
body: {
phase: "application",
type: "ok",
status_code: 200,
referrer: iframe_url,
},
metadata: {
content_type: "application/reports+json",
},
},
// Signed Exchange NEL report for the sub resource signed exchange.
{
url: sub_outer_url,
user_agent: navigator.userAgent,
type: "network-error",
body: {
phase: "sxg",
type: "ok",
status_code: 200,
referrer: iframe_url,
sxg: {
outer_url: sub_outer_url,
inner_url: sub_inner_url,
cert_url: [cert_url]
}
},
metadata: {
content_type: "application/reports+json",
},
},
]));
}, 'Subresource signed exchange prefetch.');
</script>
</body>
|