mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Update FetchTaskTarget to propagate CSP violations. (#36409)
It also updates the FetchResponseListener to process CSP violations to ensure that iframe elements (amongst others) properly generate the CSP events. These iframe elements are used in the Trusted Types tests themselves and weren't propagating the violations before. However, the tests themselves are still not passing since they also use Websockets, which currently aren't using the fetch machinery itself. That is fixed as part of [1]. [1]: https://github.com/servo/servo/issues/35028 --------- Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Signed-off-by: Josh Matthews <josh@joshmatthews.net> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
5d84acc06e
commit
85e4a2b5c7
146 changed files with 511 additions and 612 deletions
|
@ -7,6 +7,7 @@ use std::cell::Cell;
|
|||
use std::ptr;
|
||||
|
||||
use constellation_traits::BlobImpl;
|
||||
use content_security_policy::Violation;
|
||||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
|
@ -266,6 +267,7 @@ impl WebSocketMethods<crate::DomTypeHolder> for WebSocket {
|
|||
.service_workers_mode(ServiceWorkersMode::None)
|
||||
.credentials_mode(CredentialsMode::Include)
|
||||
.cache_mode(CacheMode::NoCache)
|
||||
.policy_container(global.policy_container())
|
||||
.redirect_mode(RedirectMode::Error);
|
||||
|
||||
let channels = FetchChannels::WebSocket {
|
||||
|
@ -280,6 +282,13 @@ impl WebSocketMethods<crate::DomTypeHolder> for WebSocket {
|
|||
ROUTER.add_typed_route(
|
||||
dom_event_receiver.to_ipc_receiver(),
|
||||
Box::new(move |message| match message.unwrap() {
|
||||
WebSocketNetworkEvent::ReportCSPViolations(violations) => {
|
||||
let task = ReportCSPViolationTask {
|
||||
websocket: address.clone(),
|
||||
violations,
|
||||
};
|
||||
task_source.queue(task);
|
||||
},
|
||||
WebSocketNetworkEvent::ConnectionEstablished { protocol_in_use } => {
|
||||
let open_thread = ConnectionEstablishedTask {
|
||||
address: address.clone(),
|
||||
|
@ -454,6 +463,18 @@ impl WebSocketMethods<crate::DomTypeHolder> for WebSocket {
|
|||
}
|
||||
}
|
||||
|
||||
struct ReportCSPViolationTask {
|
||||
websocket: Trusted<WebSocket>,
|
||||
violations: Vec<Violation>,
|
||||
}
|
||||
|
||||
impl TaskOnce for ReportCSPViolationTask {
|
||||
fn run_once(self) {
|
||||
let global = self.websocket.root().global();
|
||||
global.report_csp_violations(self.violations);
|
||||
}
|
||||
}
|
||||
|
||||
/// Task queued when *the WebSocket connection is established*.
|
||||
/// <https://html.spec.whatwg.org/multipage/#feedback-from-the-protocol:concept-websocket-established>
|
||||
struct ConnectionEstablishedTask {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue