diff options
-rw-r--r-- | components/script/dom/htmliframeelement.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index b7540344c6a..658961a1725 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -76,6 +76,7 @@ pub struct HTMLIFrameElement { sandbox_allowance: Cell<Option<SandboxAllowance>>, load_blocker: DomRefCell<Option<LoadBlocker>>, visibility: Cell<bool>, + name: DomRefCell<DOMString>, } impl HTMLIFrameElement { @@ -223,6 +224,16 @@ impl HTMLIFrameElement { return; } + // https://html.spec.whatwg.org/multipage/#attr-iframe-name + // Note: the spec says to set the name 'when the nested browsing context is created'. + // The current implementation sets the name on the window, + // when the iframe attributes are first processed. + if mode == ProcessingMode::FirstTime { + if let Some(window) = self.GetContentWindow() { + window.set_name(self.name.borrow().clone()) + } + } + let url = self.get_url(); // TODO: check ancestor browsing contexts for same URL @@ -299,6 +310,7 @@ impl HTMLIFrameElement { sandbox_allowance: Cell::new(None), load_blocker: DomRefCell::new(None), visibility: Cell::new(true), + name: DomRefCell::new(DOMString::new()) } } @@ -471,6 +483,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { // https://html.spec.whatwg.org/multipage/#dom-iframe-name fn SetName(&self, name: DOMString) { + *self.name.borrow_mut() = name.clone(); if let Some(window) = self.GetContentWindow() { window.set_name(name) } @@ -481,7 +494,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { if let Some(window) = self.GetContentWindow() { window.get_name() } else { - DOMString::new() + self.name.borrow().clone() } } } |