Forward CSP violations from load_whole_resource to parent event loop (#38048)

Any CSP violations happening when loading a worker should be reported
on the global of the document that creates the worker. Since workers
run in different threads, we can't pass in this parent global into
the worker global scope. Instead, we need to send a message to the
parent event loop to report it on the correct global.

Part of https://github.com/servo/servo/issues/4577
Fixes https://github.com/servo/servo/issues/37027

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
Tim van der Lippe 2025-07-20 18:00:28 +02:00 committed by GitHub
parent 772c84633e
commit 20386d9854
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 152 additions and 531 deletions

View file

@ -2087,6 +2087,14 @@ impl ScriptThread {
MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(chan)) => {
self.collect_reports(chan)
},
MainThreadScriptMsg::Common(CommonScriptMsg::ReportCspViolations(
pipeline_id,
violations,
)) => {
if let Some(global) = self.documents.borrow().find_global(pipeline_id) {
global.report_csp_violations(violations, None, None);
}
},
MainThreadScriptMsg::NavigationResponse {
pipeline_id,
message,