Skip to content

Conversation

@theIDinside
Copy link
Contributor

This addresses the test described in #55888 that seemingly breaks with spec. This is a suggested edit, as it still keeps what the original test intends to test for, but a test should probably also be written, where this test returns source file null and line/column numbers as 0/null.

We've removed the src attribute from img to not trigger an immediate load. The spec says that only when javascript is running, source file, line number and column should be reported as per 2.4.1 https://w3c.github.io/webappsec-csp/#create-violation-for-global in step 2.

This change will make the load happen when script is actually running, on line 54 and line 54 should therefore be reported.

We've removed the src attribute from img to not trigger an immediate load. The spec says that only when javascript is running, source file, line number and column should be reported as per 2.4.1 https://w3c.github.io/webappsec-csp/#create-violation-for-global in step 2.

This change will make the load happen when script is actually running, on line 54 and line 54 should therefore be reported.
theImage.src = '/content-security-policy/support/fail.png'
</script>

<script async defer src='../support/checkReport.sub.js?reportField=effectiveDirective&reportValue=img-src%20%27none%27'></script>
Copy link
Contributor Author

@theIDinside theIDinside Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line number it would previously report for. Which does not make much sense and chrome is returning information that will not make sense for the end user here, because the violation actualy happens on line 49, inside the <img> tag.

assert_equals(reports[0].body.statusCode, 200);
assert_equals(reports[0].body.lineNumber, 53);
assert_equals(reports[0].body.lineNumber, 54);
assert_equals(reports[0].body.columnNumber, 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (the column value) would also change now that I think about it, to 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants