Skip to content

Commit aaee91a

Browse files
TimvdLippeservo-wpt-sync
authored andcommitted
Fix reporting when only the report-only CSP header is present
This was a bit confusing at first, but the report-only only had an effect if it was used in conjunction with the regular CSP header. This is incorrect, as the report-only header can be present on its own. Additionally, there was double-logic for parsing the CSP list values, since we can only concatenate CSP lists if we have an initial value, which requires a concrete policy value. Therefore, abstract that way by looping over both headers and handling the case where initially it is `None` and, if the CSP header is not present, still `None` when we parse the `report-only` header. Additionally, update two WPT tests. One was expecting the image to load, yet was showing the fail image. The other one is currently still failing for Servo, but crashes the test runner. Now it no longer times out, but has the wrong value for number of reports. Part of #4577 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
1 parent 1570919 commit aaee91a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

content-security-policy/reporting-api/reporting-api-report-only-sends-reports-on-violation.https.sub.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
</head>
88
<body>
99
<script>
10-
var t1 = async_test("Test that image does not load");
10+
var t1 = async_test("Test that image does load");
1111
async_test(function(t2) {
1212
window.addEventListener("securitypolicyviolation", t2.step_func(function(e) {
13-
assert_equals(e.blockedURI, "{{location[scheme]}}://{{location[host]}}/content-security-policy/support/fail.png");
13+
assert_equals(e.blockedURI, "{{location[scheme]}}://{{location[host]}}/content-security-policy/support/pass.png");
1414
assert_equals(e.violatedDirective, "img-src");
1515
t2.done();
1616
}));
1717
}, "Event is fired");
1818
</script>
19-
<img src='/content-security-policy/support/fail.png'
19+
<img src='/content-security-policy/support/pass.png'
2020
onload='t1.done();'
2121
onerror='t1.unreached_func("The image should have loaded");'>
2222

0 commit comments

Comments
 (0)