From 41230fe03dff7f8c0fe72cd241dbc1ec9928021e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Sat, 11 Jun 2016 01:24:20 +0300 Subject: [PATCH 1/2] Change sandbox to sandbox_allowance in HTMLIFrameElement --- components/script/dom/htmliframeelement.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 1c0e0c9cf1a..b203f1f6e8a 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -63,13 +63,13 @@ pub struct HTMLIFrameElement { htmlelement: HTMLElement, pipeline_id: Cell>, subpage_id: Cell>, - sandbox: Cell>, + sandbox_allowance: Cell>, load_blocker: DOMRefCell>, } impl HTMLIFrameElement { pub fn is_sandboxed(&self) -> bool { - self.sandbox.get().is_some() + self.sandbox_allowance.get().is_some() } /// , @@ -193,7 +193,7 @@ impl HTMLIFrameElement { htmlelement: HTMLElement::new_inherited(localName, prefix, document), pipeline_id: Cell::new(None), subpage_id: Cell::new(None), - sandbox: Cell::new(None), + sandbox_allowance: Cell::new(None), load_blocker: DOMRefCell::new(None), } } @@ -515,7 +515,7 @@ impl VirtualMethods for HTMLIFrameElement { self.super_type().unwrap().attribute_mutated(attr, mutation); match attr.local_name() { &atom!("sandbox") => { - self.sandbox.set(mutation.new_value(attr).map(|value| { + self.sandbox_allowance.set(mutation.new_value(attr).map(|value| { let mut modes = SandboxAllowance::AllowNothing as u8; for token in value.as_tokens() { modes |= match &*token.to_ascii_lowercase() { From 47984a52c6e0976f0dd5c36506b2c9b7ba8c180d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Sat, 11 Jun 2016 01:59:59 +0300 Subject: [PATCH 2/2] Add Sandbox field to HTMLIFrameElement --- components/script/dom/htmliframeelement.rs | 14 ++++++-------- .../script/dom/webidls/HTMLIFrameElement.webidl | 3 ++- .../DOMTokenList-coverage-for-attributes.html.ini | 3 --- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index b203f1f6e8a..53fe45584b8 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -19,11 +19,12 @@ use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::error::{Error, ErrorResult}; use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{Root, LayoutJS}; +use dom::bindings::js::{JS, MutNullableHeap, Root, LayoutJS}; use dom::bindings::reflector::Reflectable; use dom::bindings::str::DOMString; use dom::customevent::CustomEvent; use dom::document::Document; +use dom::domtokenlist::DOMTokenList; use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers}; use dom::event::Event; use dom::eventtarget::EventTarget; @@ -63,6 +64,7 @@ pub struct HTMLIFrameElement { htmlelement: HTMLElement, pipeline_id: Cell>, subpage_id: Cell>, + sandbox: MutNullableHeap>, sandbox_allowance: Cell>, load_blocker: DOMRefCell>, } @@ -193,6 +195,7 @@ impl HTMLIFrameElement { htmlelement: HTMLElement::new_inherited(localName, prefix, document), pipeline_id: Cell::new(None), subpage_id: Cell::new(None), + sandbox: Default::default(), sandbox_allowance: Cell::new(None), load_blocker: DOMRefCell::new(None), } @@ -412,13 +415,8 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { } // https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox - fn Sandbox(&self) -> DOMString { - self.upcast::().get_string_attribute(&atom!("sandbox")) - } - - // https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox - fn SetSandbox(&self, sandbox: DOMString) { - self.upcast::().set_tokenlist_attribute(&atom!("sandbox"), sandbox); + fn Sandbox(&self) -> Root { + self.sandbox.or_init(|| DOMTokenList::new(self.upcast::(), &atom!("sandbox"))) } // https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow diff --git a/components/script/dom/webidls/HTMLIFrameElement.webidl b/components/script/dom/webidls/HTMLIFrameElement.webidl index 65ccbe84048..b448ab0ca4f 100644 --- a/components/script/dom/webidls/HTMLIFrameElement.webidl +++ b/components/script/dom/webidls/HTMLIFrameElement.webidl @@ -7,7 +7,8 @@ interface HTMLIFrameElement : HTMLElement { attribute DOMString src; // attribute DOMString srcdoc; // attribute DOMString name; - attribute DOMString sandbox; + [SameObject, PutForwards=value] + readonly attribute DOMTokenList sandbox; // attribute boolean seamless; // attribute boolean allowFullscreen; attribute DOMString width; diff --git a/tests/wpt/metadata/dom/lists/DOMTokenList-coverage-for-attributes.html.ini b/tests/wpt/metadata/dom/lists/DOMTokenList-coverage-for-attributes.html.ini index b50efb72c7f..ed70e7acb55 100644 --- a/tests/wpt/metadata/dom/lists/DOMTokenList-coverage-for-attributes.html.ini +++ b/tests/wpt/metadata/dom/lists/DOMTokenList-coverage-for-attributes.html.ini @@ -36,9 +36,6 @@ [area.ping in http://www.w3.org/1999/xhtml namespace should be DOMTokenList.] expected: FAIL - [iframe.sandbox in http://www.w3.org/1999/xhtml namespace should be DOMTokenList.] - expected: FAIL - [link.sizes in http://www.w3.org/1999/xhtml namespace should be DOMTokenList.] expected: FAIL