From a0082c57c8bb9a1c62f03bffa3f636e0791ee7b3 Mon Sep 17 00:00:00 2001 From: Gregory Terzian Date: Sun, 3 Jun 2018 22:59:36 +0800 Subject: [PATCH] iframe: use value of name attr to set nested bc name --- components/script/dom/htmliframeelement.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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>, load_blocker: DomRefCell>, visibility: Cell, + name: DomRefCell, } 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() } } }