diff options
Diffstat (limited to 'components/script/dom/servoparser/mod.rs')
-rw-r--r-- | components/script/dom/servoparser/mod.rs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index 0650fde676e..3a1efdfb291 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -21,6 +21,7 @@ use html5ever::{Attribute, ExpandedName, LocalName, QualName, local_name, ns}; use hyper_serde::Serde; use markup5ever::TokenizerResult; use mime::{self, Mime}; +use net_traits::policy_container::PolicyContainer; use net_traits::request::RequestId; use net_traits::{ FetchMetadata, FetchResponseListener, Metadata, NetworkError, ResourceFetchTiming, @@ -356,16 +357,14 @@ impl ServoParser { } /// Steps 6-8 of <https://html.spec.whatwg.org/multipage/#document.write()> - pub(crate) fn write(&self, text: Vec<DOMString>, can_gc: CanGc) { + pub(crate) fn write(&self, text: DOMString, can_gc: CanGc) { assert!(self.can_write()); if self.document.has_pending_parsing_blocking_script() { // There is already a pending parsing blocking script so the // parser is suspended, we just append everything to the // script input and abort these steps. - for chunk in text { - self.script_input.push_back(String::from(chunk).into()); - } + self.script_input.push_back(String::from(text).into()); return; } @@ -375,9 +374,7 @@ impl ServoParser { assert!(self.script_input.is_empty()); let input = BufferQueue::default(); - for chunk in text { - input.push_back(String::from(chunk).into()); - } + input.push_back(String::from(text).into()); let profiler_chan = self .document @@ -813,6 +810,27 @@ impl ParserContext { pushed_entry_index: None, } } + + pub(crate) fn append_parent_to_csp_list(&self, policy_container: Option<&PolicyContainer>) { + let Some(policy_container) = policy_container else { + return; + }; + let Some(parent_csp_list) = &policy_container.csp_list else { + return; + }; + let Some(parser) = self.parser.as_ref().map(|p| p.root()) else { + return; + }; + let new_csp_list = match parser.document.get_csp_list() { + None => parent_csp_list.clone(), + Some(original_csp_list) => { + let mut appended_csp_list = original_csp_list.clone(); + appended_csp_list.append(parent_csp_list.clone()); + appended_csp_list.to_owned() + }, + }; + parser.document.set_csp_list(Some(new_csp_list)); + } } impl FetchResponseListener for ParserContext { |