commit f80917fcbd2be2aa692ec517bbe2054486f08d2d
parent 9f0b1c96f7918d1ead5cb1089ebfaf9bb6f63234
Author: Valentin Gosu <valentin.gosu@gmail.com>
Date: Fri, 12 Dec 2025 14:06:16 +0000
Bug 1976061 - Add WPT for NEL with v1 reporting headers: Reporting-Endpoints r=necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D273219
Diffstat:
4 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/network-error-logging/sends-report-on-success-v1.https.html b/testing/web-platform/tests/network-error-logging/sends-report-on-success-v1.https.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>
+ Test that NEL reports are sent for successful requests
+ </title>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ <script src='./support/nel.sub.js'></script>
+</head>
+<body>
+ <script>
+ nel_test(async t => {
+ // Make a request to a resource whose response headers include a NEL
+ // policy.
+ await fetchResourceWithBasicPolicyv1();
+ // That policy should apply to the request that delivered it, so the
+ // collector should have received a report about the request.
+ assert_true(await reportExists({
+ url: getURLForResourceWithBasicPolicyv1(),
+ user_agent: navigator.userAgent,
+ type: "network-error",
+ body: {
+ method: "GET",
+ sampling_fraction: 1.0,
+ status_code: 200,
+ phase: "application",
+ type: "ok",
+ },
+ metadata: {
+ content_type: "application/reports+json",
+ },
+ }));
+ });
+ </script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/network-error-logging/support/nel.sub.js b/testing/web-platform/tests/network-error-logging/support/nel.sub.js
@@ -69,6 +69,10 @@ function getURLForResourceWithBasicPolicy(subdomain) {
return _getNELResourceURL(subdomain, "pass.png?id="+reportID+"&success_fraction=1.0");
}
+function getURLForResourceWithBasicPolicyv1(subdomain) {
+ return _getNELResourceURL(subdomain, "pass2.png?id="+reportID+"&success_fraction=1.0");
+}
+
function getSanitizedURLForResourceWithNoPolicy(subdomain) {
return _getNELResourceURL(subdomain, "no-policy-pass.png", { sanitize: true });
}
@@ -78,6 +82,11 @@ function fetchResourceWithBasicPolicy(subdomain) {
return fetch(url, {mode: "no-cors"});
}
+function fetchResourceWithBasicPolicyv1(subdomain) {
+ const url = getURLForResourceWithBasicPolicyv1(subdomain);
+ return fetch(url, {mode: "no-cors"});
+}
+
function fetchResourceWithZeroSuccessFractionPolicy(subdomain) {
const url = _getNELResourceURL(subdomain, "pass.png?id="+reportID+"&success_fraction=0.0");
return fetch(url, {mode: "no-cors"});
diff --git a/testing/web-platform/tests/network-error-logging/support/pass2.png b/testing/web-platform/tests/network-error-logging/support/pass2.png
Binary files differ.
diff --git a/testing/web-platform/tests/network-error-logging/support/pass2.png.sub.headers b/testing/web-platform/tests/network-error-logging/support/pass2.png.sub.headers
@@ -0,0 +1,6 @@
+Expires: Mon, 26 Jul 1997 05:00:00 GMT
+Cache-Control: no-store, no-cache, must-revalidate
+Cache-Control: post-check=0, pre-check=0, false
+Pragma: no-cache
+Reporting-Endpoints: nel-group="https://{{hosts[][www]}}:{{ports[https][0]}}/reporting/resources/report.py?op=put&reportID={{GET[id]}}"
+NEL: {"report_to": "nel-group", "max_age": 10886400, "success_fraction": {{GET[success_fraction]}}}