diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-09-08 02:29:00 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-09-08 02:29:00 -0600 |
commit | 5a0be12e43f92fc64b1d8f5d35f9dadaa4b53521 (patch) | |
tree | 8ff86e125befb904f63980c245b21129f126c6fa | |
parent | 282f9ade931342e9cd1ae72fde9dd9f88cb5b34a (diff) | |
parent | b3820047da0810b528800c385063a79c013cd0d6 (diff) | |
download | servo-5a0be12e43f92fc64b1d8f5d35f9dadaa4b53521.tar.gz servo-5a0be12e43f92fc64b1d8f5d35f9dadaa4b53521.zip |
Auto merge of #7531 - nox:template, r=Ms2ger
Implement <template>
All tests using iframes can't currently pass, same for innerHTML-related tests with <template> elements. The latter contradicts the spec, see the links below.
Apart from this, they work, AFAICT.
https://github.com/servo/html5ever/issues/164
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27314
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7531)
<!-- Reviewable:end -->
28 files changed, 268 insertions, 57 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index dec403e633b..74528cac9df 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -155,6 +155,9 @@ pub struct Document { reflow_timeout: Cell<Option<u64>>, /// The cached first `base` element with an `href` attribute. base_element: MutNullableHeap<JS<HTMLBaseElement>>, + /// This field is set to the document itself for inert documents. + /// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document + appropriate_template_contents_owner_document: MutNullableHeap<JS<Document>>, } impl PartialEq for Document { @@ -1058,6 +1061,7 @@ impl Document { current_parser: Default::default(), reflow_timeout: Cell::new(None), base_element: Default::default(), + appropriate_template_contents_owner_document: Default::default(), } } @@ -1106,6 +1110,23 @@ impl Document { .and_then(HTMLHtmlElementCast::to_ref) .map(Root::from_ref) } + + /// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document + pub fn appropriate_template_contents_owner_document(&self) -> Root<Document> { + self.appropriate_template_contents_owner_document.or_init(|| { + let doctype = if self.is_html_document { + IsHTMLDocument::HTMLDocument + } else { + IsHTMLDocument::NonHTMLDocument + }; + let new_doc = Document::new( + &*self.window(), None, doctype, None, None, + DocumentSource::NotFromParser, DocumentLoader::new(&self.loader())); + new_doc.appropriate_template_contents_owner_document.set( + Some(JS::from_ref(&*new_doc))); + new_doc + }) + } } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 3d79189a07e..27e8e9c7b7e 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -13,19 +13,18 @@ use dom::bindings::codegen::Bindings::ElementBinding; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; +use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use dom::bindings::codegen::InheritTypes::CharacterDataCast; -use dom::bindings::codegen::InheritTypes::DocumentDerived; -use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast; -use dom::bindings::codegen::InheritTypes::TextCast; -use dom::bindings::codegen::InheritTypes::{ElementCast, ElementDerived, EventTargetCast}; +use dom::bindings::codegen::InheritTypes::{CharacterDataCast, DocumentDerived, ElementCast}; +use dom::bindings::codegen::InheritTypes::{ElementDerived, EventTargetCast, HTMLAnchorElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLBodyElementDerived, HTMLFontElementDerived}; use dom::bindings::codegen::InheritTypes::{HTMLIFrameElementDerived, HTMLInputElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLTableElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, HTMLTableCellElementDerived}; -use dom::bindings::codegen::InheritTypes::{HTMLTableRowElementDerived, HTMLTextAreaElementDerived}; -use dom::bindings::codegen::InheritTypes::{HTMLTableSectionElementDerived, NodeCast}; +use dom::bindings::codegen::InheritTypes::{HTMLTableRowElementDerived, HTMLTableSectionElementDerived}; +use dom::bindings::codegen::InheritTypes::{HTMLTemplateElementCast, HTMLTextAreaElementDerived}; +use dom::bindings::codegen::InheritTypes::{NodeCast, TextCast}; use dom::bindings::codegen::UnionTypes::NodeOrString; use dom::bindings::error::Error::NoModificationAllowed; use dom::bindings::error::Error::{InvalidCharacter, Syntax}; @@ -1280,19 +1279,25 @@ impl ElementMethods for Element { node.get_client_rect().size.height } - // https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML + /// https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML fn GetInnerHTML(&self) -> Fallible<DOMString> { //XXX TODO: XML case self.serialize(ChildrenOnly) } - // https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML + /// https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML fn SetInnerHTML(&self, value: DOMString) -> Fallible<()> { let context_node = NodeCast::from_ref(self); // Step 1. let frag = try!(context_node.parse_fragment(value)); // Step 2. - Node::replace_all(Some(NodeCast::from_ref(frag.r())), context_node); + // https://github.com/w3c/DOM-Parsing/issues/1 + let target = if let Some(template) = HTMLTemplateElementCast::to_ref(self) { + NodeCast::from_root(template.Content()) + } else { + Root::from_ref(context_node) + }; + Node::replace_all(Some(NodeCast::from_ref(&*frag)), &target); Ok(()) } diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs index 86e69b31a64..0a4aa7b8786 100644 --- a/components/script/dom/htmltemplateelement.rs +++ b/components/script/dom/htmltemplateelement.rs @@ -2,19 +2,28 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding; -use dom::bindings::codegen::InheritTypes::HTMLTemplateElementDerived; -use dom::bindings::js::Root; +use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; +use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; +use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTemplateElementCast}; +use dom::bindings::codegen::InheritTypes::{HTMLTemplateElementDerived, NodeCast}; +use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::document::Document; +use dom::documentfragment::DocumentFragment; use dom::element::ElementTypeId; use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; -use dom::node::{Node, NodeTypeId}; +use dom::node::{CloneChildrenFlag, Node, NodeTypeId, document_from_node}; +use dom::virtualmethods::VirtualMethods; use util::str::DOMString; #[dom_struct] pub struct HTMLTemplateElement { htmlelement: HTMLElement, + + /// https://html.spec.whatwg.org/multipage/#template-contents + contents: MutNullableHeap<JS<DocumentFragment>>, } impl HTMLTemplateElementDerived for EventTarget { @@ -31,7 +40,8 @@ impl HTMLTemplateElement { document: &Document) -> HTMLTemplateElement { HTMLTemplateElement { htmlelement: - HTMLElement::new_inherited(HTMLElementTypeId::HTMLTemplateElement, localName, prefix, document) + HTMLElement::new_inherited(HTMLElementTypeId::HTMLTemplateElement, localName, prefix, document), + contents: MutNullableHeap::new(None), } } @@ -43,3 +53,47 @@ impl HTMLTemplateElement { Node::reflect_node(box element, document, HTMLTemplateElementBinding::Wrap) } } + +impl HTMLTemplateElementMethods for HTMLTemplateElement { + /// https://html.spec.whatwg.org/multipage/#dom-template-content + fn Content(&self) -> Root<DocumentFragment> { + self.contents.or_init(|| { + let doc = document_from_node(self); + doc.appropriate_template_contents_owner_document().CreateDocumentFragment() + }) + } +} + +impl VirtualMethods for HTMLTemplateElement { + fn super_type(&self) -> Option<&VirtualMethods> { + Some(HTMLElementCast::from_ref(self) as &VirtualMethods) + } + + /// https://html.spec.whatwg.org/multipage/#template-adopting-steps + fn adopting_steps(&self, old_doc: &Document) { + self.super_type().unwrap().adopting_steps(old_doc); + // Step 1. + let doc = document_from_node(self).appropriate_template_contents_owner_document(); + // Step 2. + Node::adopt(NodeCast::from_ref(&*self.Content()), &doc); + } + + /// https://html.spec.whatwg.org/multipage/#the-template-element:concept-node-clone-ext + fn cloning_steps(&self, copy: &Node, maybe_doc: Option<&Document>, + clone_children: CloneChildrenFlag) { + self.super_type().unwrap().cloning_steps(copy, maybe_doc, clone_children); + if clone_children == CloneChildrenFlag::DoNotCloneChildren { + // Step 1. + return; + } + let copy = HTMLTemplateElementCast::to_ref(copy).unwrap(); + // Steps 2-3. + let copy_contents = NodeCast::from_root(copy.Content()); + let copy_contents_doc = copy_contents.owner_doc(); + for child in NodeCast::from_root(self.Content()).children() { + let copy_child = Node::clone( + &child, Some(©_contents_doc), CloneChildrenFlag::CloneChildren); + copy_contents.AppendChild(©_child).unwrap(); + } + } +} diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index f46cbc0be11..b0c8d79228e 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1415,24 +1415,19 @@ impl Node { // https://dom.spec.whatwg.org/#concept-node-adopt pub fn adopt(node: &Node, document: &Document) { // Step 1. - let parent_node = node.GetParentNode(); - match parent_node { - Some(ref parent) => { - Node::remove(node, parent, SuppressObserver::Unsuppressed); - } - None => (), - } - + let old_doc = node.owner_doc(); // Step 2. - let node_doc = document_from_node(node); - if node_doc.r() != document { + node.remove_self(); + if &*old_doc != document { + // Step 3. for descendant in node.traverse_preorder() { - descendant.r().set_owner_doc(document); + descendant.set_owner_doc(document); + } + // Step 4. + for descendant in node.traverse_preorder() { + vtable_for(&descendant).adopting_steps(&old_doc); } } - - // Step 3. - // If node is an element, it is _affected by a base URL change_. } // https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 6812703ffe6..135670cbbc3 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -30,6 +30,7 @@ use dom::bindings::codegen::InheritTypes::HTMLTableCellElementCast; use dom::bindings::codegen::InheritTypes::HTMLTableElementCast; use dom::bindings::codegen::InheritTypes::HTMLTableRowElementCast; use dom::bindings::codegen::InheritTypes::HTMLTableSectionElementCast; +use dom::bindings::codegen::InheritTypes::HTMLTemplateElementCast; use dom::bindings::codegen::InheritTypes::HTMLTextAreaElementCast; use dom::bindings::codegen::InheritTypes::HTMLTitleElementCast; use dom::document::Document; @@ -98,7 +99,14 @@ pub trait VirtualMethods { } } - /// https://dom.spec.whatwg.org/#concept-node-clone (step 5) + /// https://dom.spec.whatwg.org/#concept-node-adopt-ext + fn adopting_steps(&self, old_doc: &Document) { + if let Some(ref s) = self.super_type() { + s.adopting_steps(old_doc); + } + } + + /// https://dom.spec.whatwg.org/#concept-node-clone-ext fn cloning_steps(&self, copy: &Node, maybe_doc: Option<&Document>, clone_children: CloneChildrenFlag) { if let Some(ref s) = self.super_type() { @@ -216,6 +224,9 @@ pub fn vtable_for<'a>(node: &'a Node) -> &'a (VirtualMethods + 'a) { HTMLTableSectionElementCast::to_ref(node).unwrap(); element as &'a (VirtualMethods + 'a) } + NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTemplateElement)) => { + HTMLTemplateElementCast::to_ref(node).unwrap() as &'a (VirtualMethods + 'a) + } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) => { let element = HTMLTextAreaElementCast::to_ref(node).unwrap(); element as &'a (VirtualMethods + 'a) diff --git a/components/script/dom/webidls/HTMLTemplateElement.webidl b/components/script/dom/webidls/HTMLTemplateElement.webidl index 66a1dd6ef62..fc497ea9f15 100644 --- a/components/script/dom/webidls/HTMLTemplateElement.webidl +++ b/components/script/dom/webidls/HTMLTemplateElement.webidl @@ -5,5 +5,5 @@ // https://www.whatwg.org/html/#htmltemplateelement interface HTMLTemplateElement : HTMLElement { - //readonly attribute DocumentFragment content; + readonly attribute DocumentFragment content; }; diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index a2dd0109ed1..7a0ae327008 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -6,11 +6,12 @@ use document_loader::DocumentLoader; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; +use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use dom::bindings::codegen::InheritTypes::ProcessingInstructionCast; use dom::bindings::codegen::InheritTypes::{CharacterDataCast, DocumentTypeCast}; -use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLScriptElementCast}; -use dom::bindings::codegen::InheritTypes::{HTMLFormElementDerived, NodeCast}; +use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFormElementDerived}; +use dom::bindings::codegen::InheritTypes::{HTMLScriptElementCast, HTMLTemplateElementCast}; +use dom::bindings::codegen::InheritTypes::{NodeCast, ProcessingInstructionCast}; use dom::bindings::js::{JS, Root}; use dom::bindings::js::{RootedReference}; use dom::characterdata::CharacterDataTypeId; @@ -43,12 +44,20 @@ use util::str::DOMString; impl<'a> TreeSink for servohtmlparser::Sink { type Handle = JS<Node>; + fn get_document(&mut self) -> JS<Node> { let doc = self.document.root(); let node = NodeCast::from_ref(doc.r()); JS::from_ref(node) } + fn get_template_contents(&self, target: JS<Node>) -> JS<Node> { + let target = target.root(); + let template = HTMLTemplateElementCast::to_ref(&*target) + .expect("tried to get template contents of non-HTMLTemplateElement in HTML parsing"); + JS::from_ref(NodeCast::from_ref(&*template.Content())) + } + fn same_node(&self, x: JS<Node>, y: JS<Node>) -> bool { x == y } @@ -194,7 +203,14 @@ impl<'a> Serializable for &'a Node { try!(serializer.start_elem(name.clone(), attr_refs)); } - for handle in node.children() { + let children = if let Some(tpl) = HTMLTemplateElementCast::to_ref(node) { + // https://github.com/w3c/DOM-Parsing/issues/1 + NodeCast::from_ref(&*tpl.Content()).children() + } else { + node.children() + }; + + for handle in children { try!(handle.r().serialize(serializer, IncludeNode)); } diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index a94409231af..eb881246204 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -750,7 +750,7 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "html5ever_macros 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1375,7 +1375,7 @@ dependencies = [ "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "html5ever 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "html5ever 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs)", @@ -1738,7 +1738,7 @@ dependencies = [ "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "html5ever 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "html5ever 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs)", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 7b7a6ad2136..0db6dbd4b8d 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -735,7 +735,7 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "html5ever_macros 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1345,7 +1345,7 @@ dependencies = [ "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "html5ever 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "html5ever 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs)", @@ -1699,7 +1699,7 @@ dependencies = [ "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "html5ever 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "html5ever 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 4e9c42aa6c5..218aa7e9d20 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -619,7 +619,7 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "html5ever_macros 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1211,7 +1211,7 @@ dependencies = [ "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "html5ever 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "html5ever 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs)", @@ -1534,7 +1534,7 @@ dependencies = [ "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "html5ever 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "html5ever 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs)", diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index 080c6d4e7d5..d8df33b0711 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -6333,9 +6333,6 @@ [HTMLTemplateElement interface: existence and properties of interface object] expected: FAIL - [HTMLTemplateElement interface: attribute content] - expected: FAIL - [HTMLCanvasElement interface: existence and properties of interface object] expected: FAIL diff --git a/tests/wpt/metadata/html/semantics/embedded-content/the-img-element/update-the-source-set.html.ini b/tests/wpt/metadata/html/semantics/embedded-content/the-img-element/update-the-source-set.html.ini index 6dedfeadca1..7748cf097bb 100644 --- a/tests/wpt/metadata/html/semantics/embedded-content/the-img-element/update-the-source-set.html.ini +++ b/tests/wpt/metadata/html/semantics/embedded-content/the-img-element/update-the-source-set.html.ini @@ -267,3 +267,6 @@ [<picture><svg><!--<font face> tag breaks out of svg--><font face=""></font><source srcset="data:,b"></source></svg><img src="data:,a" data-expect="data:,b"></picture>] expected: FAIL + [<picture><svg><!--<font face> tag breaks out of svg--></svg><font face=""></font><source srcset="data:,b"><img src="data:,a" data-expect="data:,b"></picture>] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/__dir__.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/__dir__.ini deleted file mode 100644 index 163ca23a12f..00000000000 --- a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/__dir__.ini +++ /dev/null @@ -1 +0,0 @@ -disabled: for now diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/additions-to-parsing-xhtml-documents/__dir__.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/additions-to-parsing-xhtml-documents/__dir__.ini new file mode 100644 index 00000000000..0224ba3ac45 --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/additions-to-parsing-xhtml-documents/__dir__.ini @@ -0,0 +1 @@ +disabled: XHTML diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/additions-to-serializing-xhtml-documents/__dir__.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/additions-to-serializing-xhtml-documents/__dir__.ini new file mode 100644 index 00000000000..0224ba3ac45 --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/additions-to-serializing-xhtml-documents/__dir__.ini @@ -0,0 +1 @@ +disabled: XHTML diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/additions-to-the-steps-to-clone-a-node/templates-copy-document-owner.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/additions-to-the-steps-to-clone-a-node/templates-copy-document-owner.html.ini new file mode 100644 index 00000000000..40f9199c5df --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/additions-to-the-steps-to-clone-a-node/templates-copy-document-owner.html.ini @@ -0,0 +1,5 @@ +[templates-copy-document-owner.html] + type: testharness + [ownerDocument of cloned template content is set to template content owner. Test loading HTML document from file] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.html.ini new file mode 100644 index 00000000000..059169ec00a --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.html.ini @@ -0,0 +1,8 @@ +[template-contents-owner-document-type.html] + type: testharness + [The template contents owner document type is HTML document (case when document has browsing context and the template is created by HTML parser)] + expected: FAIL + + [The template contents owner document type is HTML document (case when document has browsing context and the template is created by createElement())] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-test-002.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-test-002.html.ini new file mode 100644 index 00000000000..e7699f55db9 --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-test-002.html.ini @@ -0,0 +1,11 @@ +[template-contents-owner-test-002.html] + type: testharness + [The template contents owner document must be different from template owner document, which has browsing context. Template element is created by createElement()] + expected: FAIL + + [The template contents owner document must be different from template owner document, which has browsing context. Template element is created via innerHTML] + expected: FAIL + + [The template contents owner document must be different from template owner document, which has browsing context. Template element is created by HTML parser] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/definitions/template-contents.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/definitions/template-contents.html.ini new file mode 100644 index 00000000000..f394f7448a2 --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/definitions/template-contents.html.ini @@ -0,0 +1,14 @@ +[template-contents.html] + type: testharness + [The template contents must be a DocumentFragment (the empty template tag inside HTML file loaded in iframe)] + expected: FAIL + + [The template contents must be a DocumentFragment (non empty template tag inside HTML file loaded in iframe)] + expected: FAIL + + [The template contents must be a DocumentFragment (the template tag with some text inside HTML file loaded in iframe)] + expected: FAIL + + [The template contents must be a DocumentFragment (the template tag with nested template tag inside HTML file loaded in iframe)] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/innerhtml-on-templates/innerhtml.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/innerhtml-on-templates/innerhtml.html.ini new file mode 100644 index 00000000000..450eda06a9e --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/innerhtml-on-templates/innerhtml.html.ini @@ -0,0 +1,5 @@ +[innerhtml.html] + type: testharness + [innerHTML of template element replaces all referenced by the content attribute. Test loading of HTML document from a file] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/content-attribute.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/content-attribute.html.ini new file mode 100644 index 00000000000..5a2af5e1653 --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/content-attribute.html.ini @@ -0,0 +1,8 @@ +[content-attribute.html] + type: testharness + [Content attribute of template element is read-only. Text value of content attribute of template tag should be ignored, when loading document from a file] + expected: FAIL + + [Content attribute of template element is read-only. Test content attribute of a document loaded from a file] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/node-document-changes.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/node-document-changes.html.ini new file mode 100644 index 00000000000..a3bbe0e13e9 --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/node-document-changes.html.ini @@ -0,0 +1,11 @@ +[node-document-changes.html] + type: testharness + [Changing of template element's node document. Test document loaded from a file] + expected: FAIL + + [Changing of template element's node document. Adobt template element into a document that has a browsing context] + expected: FAIL + + [Changing of template element's node document. Test the case when both old and new owner documents of template element have browsing context] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-as-a-descendant.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-as-a-descendant.html.ini new file mode 100644 index 00000000000..9a43e6289ce --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-as-a-descendant.html.ini @@ -0,0 +1,8 @@ +[template-as-a-descendant.html] + type: testharness + [Template element as a descendant of the FRAMESET element. Template element is created by innerHTML] + expected: FAIL + + [Template element as an indirect descendant of the FRAMESET element. Template element is created by innerHTML] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-content-node-document.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-content-node-document.html.ini new file mode 100644 index 00000000000..ac620e1efbd --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-content-node-document.html.ini @@ -0,0 +1,5 @@ +[template-content-node-document.html] + type: testharness + [Node document of the template content attribute must be template contents owner. Load HTML file with multiple template elements] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-descendant-body.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-descendant-body.html.ini new file mode 100644 index 00000000000..77aa831c1a8 --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-descendant-body.html.ini @@ -0,0 +1,5 @@ +[template-descendant-body.html] + type: testharness + [Template element as a descendant of the body element. Test loading from a file] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-descendant-frameset.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-descendant-frameset.html.ini new file mode 100644 index 00000000000..9499e6c5abe --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-descendant-frameset.html.ini @@ -0,0 +1,11 @@ +[template-descendant-frameset.html] + type: testharness + [Template element as a descendant of the frameset element. Test loading from a file] + expected: FAIL + + [Template element as a descendant of the frameset element. Test template element is assigned to frameset's innerHTML)] + expected: FAIL + + [Template element as a descendant of the frameset element. Test template element appended to frameset by appendChild()] + expected: FAIL + diff --git a/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-descendant-head.html.ini b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-descendant-head.html.ini new file mode 100644 index 00000000000..ae1482660d7 --- /dev/null +++ b/tests/wpt/metadata/html/semantics/scripting-1/the-template-element/template-element/template-descendant-head.html.ini @@ -0,0 +1,5 @@ +[template-descendant-head.html] + type: testharness + [Template element as a descendant of the head element. Test loading from a file] + expected: FAIL + diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.html index c229fbfe746..0102366f6ab 100644 --- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.html +++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.html @@ -17,9 +17,12 @@ testInIFrame('../resources/template-contents.html', function(context) { var doc = context.iframes[0].contentDocument; var template = doc.querySelector('template'); + var content_owner = template.content.ownerDocument; - assert_class_string(template.content.ownerDocument, 'HTMLDocument', - 'Template content owner should be a HTML document'); + assert_class_string(content_owner, 'Document', + 'Template content owner should be a document'); + assert_equals(content_owner.createElement('DIV').localName, 'div', + 'Template content owner should be an HTML document'); }, 'The template contents owner document type is HTML document ' + '(case when document has browsing context and the template ' + @@ -29,13 +32,16 @@ testInIFrame('../resources/template-contents.html', function(context) { testInIFrame('../resources/template-contents.html', function(context) { var doc = context.iframes[0].contentDocument; var template = doc.createElement('template'); - var div = doc.createElement('div'); + var content_owner = template.content.ownerDocument; + var div = doc.createElement('DIV'); template.appendChild(div); doc.body.appendChild(template); - assert_class_string(template.content.ownerDocument, 'HTMLDocument', - 'Template content owner should be a HTML document'); + assert_class_string(content_owner, 'Document', + 'Template content owner should be a document'); + assert_equals(div.localName, 'div', + 'Template content owner should be an HTML document'); }, 'The template contents owner document type is HTML document ' + '(case when document has browsing context and the template ' + @@ -45,13 +51,16 @@ testInIFrame('../resources/template-contents.html', function(context) { test(function() { var doc = newHTMLDocument(); var template = doc.createElement('template'); - var div = doc.createElement('div'); + var content_owner = template.content.ownerDocument; + var div = doc.createElement('DIV'); template.appendChild(div); doc.body.appendChild(template); - assert_class_string(template.content.ownerDocument, 'HTMLDocument', - 'Template content owner should be a HTML document'); + assert_class_string(content_owner, 'Document', + 'Template content owner should be a document'); + assert_equals(div.localName, 'div', + 'Template content owner should be an HTML document'); }, 'The template contents owner document type is HTML document ' + '(case when document has no browsing context and the template is created ' + @@ -61,9 +70,12 @@ test(function() { var doc = newHTMLDocument(); doc.body.innerHTML = '<template><div>Hello!</div></template>'; var template = doc.querySelector('template'); + var content_owner = template.content.ownerDocument; - assert_class_string(template.content.ownerDocument, 'HTMLDocument', - 'Template content owner should be a HTML document'); + assert_class_string(content_owner, 'Document', + 'Template content owner should be a document'); + assert_equals(content_owner.createElement('DIV').localName, 'div', + 'Template content owner should be an HTML document'); }, 'The template contents owner document type is HTML document ' + '(case when document has no browsing context and the template is created via innerHTML)'); |