From c1bdd3d5ce0e971c7b3eec0dadcfaf7dd448e9a3 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Wed, 30 Nov 2016 16:19:07 +0100 Subject: [PATCH] Properly mark application/xhtml+xml documents as XML For this to work, we must remove the unimplemented!() call in Element::parse_fragment because all the tests rely on setting innerHTML. --- components/script/dom/document.rs | 2 +- components/script/dom/element.rs | 8 +- components/script/script_thread.rs | 19 ++-- .../dom/nodes/Document-createElement.html.ini | 90 ------------------- ...ument-getElementsByTagName-xhtml.xhtml.ini | 11 --- .../dom/nodes/Node-nodeName-xhtml.xhtml.ini | 5 -- .../document.write-01.xhtml.ini | 5 -- .../document.writeln-01.xhtml.ini | 5 -- 8 files changed, 9 insertions(+), 136 deletions(-) delete mode 100644 tests/wpt/metadata/dom/nodes/Document-getElementsByTagName-xhtml.xhtml.ini delete mode 100644 tests/wpt/metadata/dom/nodes/Node-nodeName-xhtml.xhtml.ini delete mode 100644 tests/wpt/metadata/html/dom/dynamic-markup-insertion/document-write/document.write-01.xhtml.ini delete mode 100644 tests/wpt/metadata/html/dom/dynamic-markup-insertion/document-writeln/document.writeln-01.xhtml.ini diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 844bc2300436..8b66d2db75d3 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -136,7 +136,7 @@ pub enum TouchEventResult { Forwarded, } -#[derive(JSTraceable, PartialEq, HeapSizeOf)] +#[derive(Clone, Copy, Debug, HeapSizeOf, JSTraceable, PartialEq)] pub enum IsHTMLDocument { HTMLDocument, NonHTMLDocument, diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 5895c374b223..c384001e33ad 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1278,12 +1278,8 @@ impl Element { pub fn parse_fragment(&self, markup: DOMString) -> Fallible> { // Steps 1-2. let context_document = document_from_node(self); - let new_children = if context_document.is_html_document() { - ServoParser::parse_html_fragment(self, markup) - } else { - // FIXME: XML case - unimplemented!() - }; + // TODO(#11995): XML case. + let new_children = ServoParser::parse_html_fragment(self, markup); // Step 3. let fragment = DocumentFragment::new(&context_document); // Step 4. diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 140d57ec7547..983d6fc8e368 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1751,9 +1751,12 @@ impl ScriptThread { Some(incomplete.url.clone())); let is_html_document = match metadata.content_type { + Some(Serde(ContentType(Mime(TopLevel::Application, SubLevel::Ext(ref sub_level), _)))) + if sub_level.ends_with("+xml") => IsHTMLDocument::NonHTMLDocument, + Some(Serde(ContentType(Mime(TopLevel::Application, SubLevel::Xml, _)))) | - Some(Serde(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _)))) => - IsHTMLDocument::NonHTMLDocument, + Some(Serde(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _)))) => IsHTMLDocument::NonHTMLDocument, + _ => IsHTMLDocument::HTMLDocument, }; @@ -1844,17 +1847,7 @@ impl ScriptThread { document.set_https_state(metadata.https_state); - let is_xml = match metadata.content_type { - Some(Serde(ContentType(Mime(TopLevel::Application, SubLevel::Ext(ref sub_level), _)))) - if sub_level.ends_with("+xml") => true, - - Some(Serde(ContentType(Mime(TopLevel::Application, SubLevel::Xml, _)))) | - Some(Serde(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _)))) => true, - - _ => false, - }; - - if is_xml { + if is_html_document == IsHTMLDocument::NonHTMLDocument { ServoParser::parse_xml_document( &document, parse_input, diff --git a/tests/wpt/metadata/dom/nodes/Document-createElement.html.ini b/tests/wpt/metadata/dom/nodes/Document-createElement.html.ini index 94eefdcffa97..1d72b6f9b01d 100644 --- a/tests/wpt/metadata/dom/nodes/Document-createElement.html.ini +++ b/tests/wpt/metadata/dom/nodes/Document-createElement.html.ini @@ -3,186 +3,96 @@ [createElement(undefined) in XML document] expected: FAIL - [createElement(undefined) in XHTML document] - expected: FAIL - [createElement(null) in XML document] expected: FAIL - [createElement(null) in XHTML document] - expected: FAIL - [createElement("foo") in XML document] expected: FAIL - [createElement("foo") in XHTML document] - expected: FAIL - [createElement("f1oo") in XML document] expected: FAIL - [createElement("f1oo") in XHTML document] - expected: FAIL - [createElement("foo1") in XML document] expected: FAIL - [createElement("foo1") in XHTML document] - expected: FAIL - [createElement("fெ") in XML document] expected: FAIL - [createElement("fெ") in XHTML document] - expected: FAIL - [createElement("fooெ") in XML document] expected: FAIL - [createElement("fooெ") in XHTML document] - expected: FAIL - [createElement(":") in XML document] expected: FAIL [createElement(":foo") in XML document] expected: FAIL - [createElement(":foo") in XHTML document] - expected: FAIL - [createElement("f:oo") in XML document] expected: FAIL - [createElement("f:oo") in XHTML document] - expected: FAIL - [createElement("foo:") in XML document] expected: FAIL - [createElement("foo:") in XHTML document] - expected: FAIL - [createElement("f:o:o") in XML document] expected: FAIL - [createElement("f:o:o") in XHTML document] - expected: FAIL - [createElement("f::oo") in XML document] expected: FAIL - [createElement("f::oo") in XHTML document] - expected: FAIL - [createElement("f::oo:") in XML document] expected: FAIL - [createElement("f::oo:") in XHTML document] - expected: FAIL - [createElement("foo:0") in XML document] expected: FAIL - [createElement("foo:0") in XHTML document] - expected: FAIL - [createElement("foo:_") in XML document] expected: FAIL - [createElement("foo:_") in XHTML document] - expected: FAIL - [createElement("foo:ெ") in XML document] expected: FAIL - [createElement("foo:ெ") in XHTML document] - expected: FAIL - [createElement("foo:fooெ") in XML document] expected: FAIL - [createElement("foo:fooெ") in XHTML document] - expected: FAIL - [createElement("fooெ:foo") in XML document] expected: FAIL - [createElement("fooெ:foo") in XHTML document] - expected: FAIL - [createElement("xml") in XML document] expected: FAIL - [createElement("xml") in XHTML document] - expected: FAIL - [createElement("xmlns") in XML document] expected: FAIL - [createElement("xmlns") in XHTML document] - expected: FAIL - [createElement("xmlfoo") in XML document] expected: FAIL - [createElement("xmlfoo") in XHTML document] - expected: FAIL - [createElement("xml:foo") in XML document] expected: FAIL - [createElement("xml:foo") in XHTML document] - expected: FAIL - [createElement("xmlns:foo") in XML document] expected: FAIL - [createElement("xmlns:foo") in XHTML document] - expected: FAIL - [createElement("xmlfoo:bar") in XML document] expected: FAIL - [createElement("xmlfoo:bar") in XHTML document] - expected: FAIL - [createElement("svg") in XML document] expected: FAIL - [createElement("svg") in XHTML document] - expected: FAIL - [createElement("math") in XML document] expected: FAIL - [createElement("math") in XHTML document] - expected: FAIL - [createElement("FOO") in XML document] expected: FAIL - [createElement("FOO") in XHTML document] - expected: FAIL - [createElement("marK") in XML document] expected: FAIL - [createElement("marK") in XHTML document] - expected: FAIL - [createElement("İnput") in XML document] expected: FAIL - [createElement("İnput") in XHTML document] - expected: FAIL - [createElement("ınput") in XML document] expected: FAIL - [createElement("ınput") in XHTML document] - expected: FAIL - [createElement("") in XML document] expected: FAIL diff --git a/tests/wpt/metadata/dom/nodes/Document-getElementsByTagName-xhtml.xhtml.ini b/tests/wpt/metadata/dom/nodes/Document-getElementsByTagName-xhtml.xhtml.ini deleted file mode 100644 index c82b65e1126d..000000000000 --- a/tests/wpt/metadata/dom/nodes/Document-getElementsByTagName-xhtml.xhtml.ini +++ /dev/null @@ -1,11 +0,0 @@ -[Document-getElementsByTagName-xhtml.xhtml] - type: testharness - [HTML element with uppercase tag name matches in XHTML documents] - expected: FAIL - - [Element in HTML namespace, no prefix, non-ascii characters in name] - expected: FAIL - - [Element in HTML namespace, prefix, non-ascii characters in name] - expected: FAIL - diff --git a/tests/wpt/metadata/dom/nodes/Node-nodeName-xhtml.xhtml.ini b/tests/wpt/metadata/dom/nodes/Node-nodeName-xhtml.xhtml.ini deleted file mode 100644 index cfa46165d0d4..000000000000 --- a/tests/wpt/metadata/dom/nodes/Node-nodeName-xhtml.xhtml.ini +++ /dev/null @@ -1,5 +0,0 @@ -[Node-nodeName-xhtml.xhtml] - type: testharness - [For Element nodes, nodeName should return the same as tagName.] - expected: FAIL - diff --git a/tests/wpt/metadata/html/dom/dynamic-markup-insertion/document-write/document.write-01.xhtml.ini b/tests/wpt/metadata/html/dom/dynamic-markup-insertion/document-write/document.write-01.xhtml.ini deleted file mode 100644 index 7f39b706b7a8..000000000000 --- a/tests/wpt/metadata/html/dom/dynamic-markup-insertion/document-write/document.write-01.xhtml.ini +++ /dev/null @@ -1,5 +0,0 @@ -[document.write-01.xhtml] - type: testharness - [document.write in XHTML] - expected: FAIL - diff --git a/tests/wpt/metadata/html/dom/dynamic-markup-insertion/document-writeln/document.writeln-01.xhtml.ini b/tests/wpt/metadata/html/dom/dynamic-markup-insertion/document-writeln/document.writeln-01.xhtml.ini deleted file mode 100644 index 1b3d64f4e6e7..000000000000 --- a/tests/wpt/metadata/html/dom/dynamic-markup-insertion/document-writeln/document.writeln-01.xhtml.ini +++ /dev/null @@ -1,5 +0,0 @@ -[document.writeln-01.xhtml] - type: testharness - [document.writeln in XHTML] - expected: FAIL -