mirror of
https://github.com/servo/servo.git
synced 2025-07-21 14:23:41 +01:00
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:
parent
772c84633e
commit
20386d9854
49 changed files with 152 additions and 531 deletions
|
@ -41,6 +41,7 @@ use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object};
|
|||
use crate::dom::bindings::root::{Dom, DomRoot, RootCollection, ThreadLocalStackRoots};
|
||||
use crate::dom::bindings::str::USVString;
|
||||
use crate::dom::bindings::trace::{CustomTraceable, JSTraceable, RootedTraceableBox};
|
||||
use crate::dom::csp::Violation;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::promise::Promise;
|
||||
#[cfg(feature = "testbinding")]
|
||||
|
@ -49,7 +50,7 @@ use crate::dom::window::Window;
|
|||
use crate::dom::workletglobalscope::{
|
||||
WorkletGlobalScope, WorkletGlobalScopeInit, WorkletGlobalScopeType, WorkletTask,
|
||||
};
|
||||
use crate::fetch::load_whole_resource;
|
||||
use crate::fetch::{CspViolationsProcessor, load_whole_resource};
|
||||
use crate::messaging::{CommonScriptMsg, MainThreadScriptMsg};
|
||||
use crate::realms::InRealm;
|
||||
use crate::script_runtime::{CanGc, Runtime, ScriptThreadEventCategory};
|
||||
|
@ -433,6 +434,12 @@ struct WorkletThreadInit {
|
|||
global_init: WorkletGlobalScopeInit,
|
||||
}
|
||||
|
||||
struct WorkletCspProcessor {}
|
||||
|
||||
impl CspViolationsProcessor for WorkletCspProcessor {
|
||||
fn process_csp_violations(&self, _violations: Vec<Violation>) {}
|
||||
}
|
||||
|
||||
/// A thread for executing worklets.
|
||||
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
|
||||
struct WorkletThread {
|
||||
|
@ -671,6 +678,7 @@ impl WorkletThread {
|
|||
request,
|
||||
&resource_fetcher,
|
||||
global_scope.upcast::<GlobalScope>(),
|
||||
&WorkletCspProcessor {},
|
||||
can_gc,
|
||||
)
|
||||
.ok()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue