diff options
author | shanehandley <1322294+shanehandley@users.noreply.github.com> | 2024-11-08 18:19:23 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-08 07:19:23 +0000 |
commit | 645176742813c423c3c5016eaba69a546b286339 (patch) | |
tree | 7b47b66bdeb596668681aa83f8cf3a64a8ff8408 /components/script/dom/globalscope.rs | |
parent | 4f6283d7fead1b2489456651185e3a8bbbc725e8 (diff) | |
download | servo-645176742813c423c3c5016eaba69a546b286339.tar.gz servo-645176742813c423c3c5016eaba69a546b286339.zip |
Implement PolicyContainer and update the default ReferrerPolicy (#33977)
* Implement PolicyContainer
Signed-off-by: Shane Handley <shanehandley@fastmail.com>
* implement small parts of fetch that interact with policy container
Signed-off-by: Shane Handley <shanehandley@fastmail.com>
* fix: allow policy container's csp list to be unset
Signed-off-by: Shane Handley <shanehandley@fastmail.com>
* fix: use the correct default policy when parsing from a token
Signed-off-by: Shane Handley <shanehandley@fastmail.com>
---------
Signed-off-by: Shane Handley <shanehandley@fastmail.com>
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r-- | components/script/dom/globalscope.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 35000732eb9..194e2439d7e 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -45,6 +45,7 @@ use net_traits::filemanager_thread::{ FileManagerResult, FileManagerThreadMsg, ReadFileProgress, RelativePos, }; use net_traits::image_cache::ImageCache; +use net_traits::policy_container::PolicyContainer; use net_traits::request::{Referrer, RequestBuilder}; use net_traits::response::HttpsState; use net_traits::{ @@ -2373,6 +2374,17 @@ impl GlobalScope { unreachable!(); } + /// <https://html.spec.whatwg.org/multipage/#concept-settings-object-policy-container> + pub fn policy_container(&self) -> PolicyContainer { + if let Some(window) = self.downcast::<Window>() { + return window.Document().policy_container().to_owned(); + } + if let Some(worker) = self.downcast::<WorkerGlobalScope>() { + return worker.policy_container().to_owned(); + } + unreachable!(); + } + /// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url) /// for this global scope. pub fn api_base_url(&self) -> ServoUrl { @@ -3116,8 +3128,8 @@ impl GlobalScope { /// <https://www.w3.org/TR/CSP/#get-csp-of-object> pub fn get_csp_list(&self) -> Option<CspList> { - if let Some(window) = self.downcast::<Window>() { - return window.Document().get_csp_list().map(|c| c.clone()); + if self.downcast::<Window>().is_some() { + return self.policy_container().csp_list; } // TODO: Worker and Worklet global scopes. None |