aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmliframeelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmliframeelement.rs')
-rw-r--r--components/script/dom/htmliframeelement.rs49
1 files changed, 47 insertions, 2 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index e58e65ea5bb..df94aeb361c 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -229,7 +229,30 @@ impl HTMLIFrameElement {
/// <https://html.spec.whatwg.org/multipage/#process-the-iframe-attributes>
fn process_the_iframe_attributes(&self, mode: ProcessingMode) {
- // TODO: srcdoc
+ if self
+ .upcast::<Element>()
+ .has_attribute(&local_name!("srcdoc"))
+ {
+ let url = ServoUrl::parse("about:srcdoc").unwrap();
+ let document = document_from_node(self);
+ let window = window_from_node(self);
+ let pipeline_id = Some(window.upcast::<GlobalScope>().pipeline_id());
+ let mut load_data = LoadData::new(
+ LoadOrigin::Script(document.origin().immutable().clone()),
+ url,
+ pipeline_id,
+ Some(Referrer::ReferrerUrl(document.url())),
+ document.get_referrer_policy(),
+ );
+ let element = self.upcast::<Element>();
+ load_data.srcdoc = String::from(element.get_string_attribute(&local_name!("srcdoc")));
+ self.navigate_or_reload_child_browsing_context(
+ load_data,
+ NavigationType::InitialAboutBlank,
+ HistoryEntryReplacement::Disabled,
+ );
+ return;
+ }
let window = window_from_node(self);
@@ -480,6 +503,12 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
make_url_setter!(SetSrc, "src");
+ // https://html.spec.whatwg.org/multipage/#dom-iframe-srcdoc
+ make_getter!(Srcdoc, "srcdoc");
+
+ // https://html.spec.whatwg.org/multipage/#dom-iframe-srcdoc
+ make_setter!(SetSrcdoc, "srcdoc");
+
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
fn Sandbox(&self) -> DomRoot<DOMTokenList> {
self.sandbox
@@ -580,13 +609,29 @@ impl VirtualMethods for HTMLIFrameElement {
modes
}));
},
+ &local_name!("srcdoc") => {
+ // https://html.spec.whatwg.org/multipage/#the-iframe-element:the-iframe-element-9
+ // "Whenever an iframe element with a non-null nested browsing context has its
+ // srcdoc attribute set, changed, or removed, the user agent must process the
+ // iframe attributes."
+ // but we can't check that directly, since the child browsing context
+ // may be in a different script thread. Instead, we check to see if the parent
+ // is in a document tree and has a browsing context, which is what causes
+ // the child browsing context to be created.
+
+ // trigger the processing of iframe attributes whenever "srcdoc" attribute is set, changed or removed
+ if self.upcast::<Node>().is_connected_with_browsing_context() {
+ debug!("iframe srcdoc modified while in browsing context.");
+ self.process_the_iframe_attributes(ProcessingMode::NotFirstTime);
+ }
+ },
&local_name!("src") => {
// https://html.spec.whatwg.org/multipage/#the-iframe-element
// "Similarly, whenever an iframe element with a non-null nested browsing context
// but with no srcdoc attribute specified has its src attribute set, changed, or removed,
// the user agent must process the iframe attributes,"
// but we can't check that directly, since the child browsing context
- // may be in a different script thread. Instread, we check to see if the parent
+ // may be in a different script thread. Instead, we check to see if the parent
// is in a document tree and has a browsing context, which is what causes
// the child browsing context to be created.
if self.upcast::<Node>().is_connected_with_browsing_context() {