mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Propagate destination through load_data (#37020)
This way, we don't always set the destination to Document (which is as the spec is written today). Instead, we set it it in the load_data, depending on which context we load it from. Doing so allows us to set the `Destination::IFrame` for navigations in iframes, enabling all frame-related CSP checks. While we currently block iframes when `frame-src` or `child-src` is set, their respective tests don't pass yet. That's because we don't yet handle the cases where we fire the correct `load` event. Also update one WPT test to correctly fail, rather than erroring. That's because it was using the wrong JS test variable. Part of #4577 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
a028291466
commit
ed469fe72f
7 changed files with 17 additions and 14 deletions
|
@ -16,6 +16,7 @@ use embedder_traits::ViewportDetails;
|
|||
use html5ever::{LocalName, Prefix, local_name, ns};
|
||||
use js::rust::HandleObject;
|
||||
use net_traits::ReferrerPolicy;
|
||||
use net_traits::request::Destination;
|
||||
use profile_traits::ipc as ProfiledIpc;
|
||||
use script_traits::{NewLayoutInfo, UpdatePipelineIdReason};
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -282,6 +283,7 @@ impl HTMLIFrameElement {
|
|||
Some(document.insecure_requests_policy()),
|
||||
document.has_trustworthy_ancestor_or_current_origin(),
|
||||
);
|
||||
load_data.destination = Destination::IFrame;
|
||||
load_data.policy_container = Some(window.as_global_scope().policy_container());
|
||||
let element = self.upcast::<Element>();
|
||||
load_data.srcdoc = String::from(element.get_string_attribute(&local_name!("srcdoc")));
|
||||
|
@ -375,6 +377,8 @@ impl HTMLIFrameElement {
|
|||
Some(document.insecure_requests_policy()),
|
||||
document.has_trustworthy_ancestor_or_current_origin(),
|
||||
);
|
||||
load_data.destination = Destination::IFrame;
|
||||
load_data.policy_container = Some(window.as_global_scope().policy_container());
|
||||
|
||||
let pipeline_id = self.pipeline_id();
|
||||
// If the initial `about:blank` page is the current page, load with replacement enabled,
|
||||
|
@ -382,10 +386,6 @@ impl HTMLIFrameElement {
|
|||
let is_about_blank =
|
||||
pipeline_id.is_some() && pipeline_id == self.about_blank_pipeline_id.get();
|
||||
|
||||
if is_about_blank {
|
||||
load_data.policy_container = Some(window.as_global_scope().policy_container());
|
||||
}
|
||||
|
||||
let history_handling = if is_about_blank {
|
||||
NavigationHistoryBehavior::Replace
|
||||
} else {
|
||||
|
@ -425,6 +425,7 @@ impl HTMLIFrameElement {
|
|||
Some(document.insecure_requests_policy()),
|
||||
document.has_trustworthy_ancestor_or_current_origin(),
|
||||
);
|
||||
load_data.destination = Destination::IFrame;
|
||||
load_data.policy_container = Some(window.as_global_scope().policy_container());
|
||||
let browsing_context_id = BrowsingContextId::new();
|
||||
let webview_id = window.window_proxy().webview_id();
|
||||
|
|
|
@ -11,7 +11,6 @@ use std::cell::Cell;
|
|||
use base::cross_process_instant::CrossProcessInstant;
|
||||
use base::id::{BrowsingContextId, PipelineId, WebViewId};
|
||||
use constellation_traits::LoadData;
|
||||
use content_security_policy::Destination;
|
||||
use crossbeam_channel::Sender;
|
||||
use embedder_traits::ViewportDetails;
|
||||
use http::header;
|
||||
|
@ -202,12 +201,13 @@ impl InProgressLoad {
|
|||
self.load_data.referrer.clone(),
|
||||
)
|
||||
.method(self.load_data.method.clone())
|
||||
.destination(Destination::Document)
|
||||
.destination(self.load_data.destination)
|
||||
.mode(RequestMode::Navigate)
|
||||
.credentials_mode(CredentialsMode::Include)
|
||||
.use_url_credentials(true)
|
||||
.pipeline_id(Some(id))
|
||||
.referrer_policy(self.load_data.referrer_policy)
|
||||
.policy_container(self.load_data.policy_container.clone().unwrap_or_default())
|
||||
.insecure_requests_policy(
|
||||
self.load_data
|
||||
.inherited_insecure_requests_policy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue