Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/Node/initial-values.html

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/Node/initial-values.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Node/initial-values.html b/third_party/WebKit/LayoutTests/fast/dom/Node/initial-values.html
index f92d582e0856ea1bd7fd1f604379491d3b8fdf36..ab46c5f526c3217f0f2835f5ee632f24b517d8bd 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/Node/initial-values.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/Node/initial-values.html
@@ -4,6 +4,185 @@
<script src="../../../resources/js-test.js"></script>
</head>
<body>
-<script src="script-tests/initial-values.js"></script>
+<script>
+description("Test creation of each type of Node and check initial values")
+
+var xmlDoc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
+
+debug("Attribute creation using createElement on an HTML doc:")
+var attr = document.createAttribute("foo");
+shouldBe("attr.nodeName", "'foo'");
+shouldBe("attr.name", "'foo'");
+// Spec: http://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createAttribute
+// Both FF and WebKit return "foo" for Attribute.localName, even though the spec says null
+shouldBe("attr.localName", "null");
+shouldBe("attr.namespaceURI", "null");
+shouldBe("attr.prefix", "null");
+shouldBe("attr.value", "''");
+
+debug("Attribute creation using createElementNS on an HTML doc:")
+attr = document.createAttributeNS("http://www.example.com", "example:foo");
+shouldBe("attr.nodeName", "'example:foo'");
+shouldBe("attr.name", "'example:foo'");
+shouldBe("attr.localName", "'foo'");
+shouldBe("attr.namespaceURI", "'http://www.example.com'");
+shouldBe("attr.prefix", "'example'");
+shouldBe("attr.nodeValue", "''");
+shouldBe("attr.value", "''");
+
+debug("Attribute creation using createElement on an XHTML doc:")
+attr = xmlDoc.createAttribute("foo");
+shouldBe("attr.nodeName", "'foo'");
+shouldBe("attr.name", "'foo'");
+// Spec: http://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createAttribute
+// Both FF and WebKit return "foo" for Attribute.localName, even though the spec says null
+shouldBe("attr.localName", "null");
+shouldBe("attr.namespaceURI", "null");
+shouldBe("attr.prefix", "null");
+shouldBe("attr.value", "''");
+
+debug("Attribute creation using createElementNS on an XHTML doc:")
+attr = xmlDoc.createAttributeNS("http://www.example.com", "example:foo");
+shouldBe("attr.nodeName", "'example:foo'");
+shouldBe("attr.name", "'example:foo'");
+shouldBe("attr.localName", "'foo'");
+shouldBe("attr.namespaceURI", "'http://www.example.com'");
+shouldBe("attr.prefix", "'example'");
+shouldBe("attr.nodeValue", "''");
+shouldBe("attr.value", "''");
+
+var comment = document.createComment("foo");
+shouldBe("comment.nodeName", "'#comment'");
+shouldBe("comment.localName", "undefined");
+shouldBe("comment.namespaceURI", "undefined");
+shouldBe("comment.nodeValue", "'foo'");
+shouldBe("comment.data", "'foo'");
+
+shouldThrow("document.createCDATASection('foo')");
+var cdata = xmlDoc.createCDATASection("foo");
+shouldBe("cdata.nodeName", "'#cdata-section'");
+shouldBe("cdata.localName", "undefined");
+shouldBe("cdata.namespaceURI", "undefined");
+shouldBe("cdata.nodeValue", "'foo'");
+shouldBe("cdata.data", "'foo'");
+
+var fragment = document.createDocumentFragment();
+shouldBe("fragment.nodeName", "'#document-fragment'");
+shouldBe("fragment.localName", "undefined");
+shouldBe("fragment.namespaceURI", "undefined");
+shouldBe("fragment.nodeValue", "null");
+
+var doc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
+shouldBe("doc.nodeName", "'#document'");
+shouldBe("doc.localName", "undefined");
+shouldBe("doc.namespaceURI", "undefined");
+shouldBe("doc.nodeValue", "null");
+
+var doctype = document.implementation.createDocumentType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd");
+shouldBe("doctype.nodeName", "'svg'");
+shouldBe("doctype.name", "'svg'");
+shouldBe("doctype.localName", "undefined");
+shouldBe("doctype.namespaceURI", "undefined");
+shouldBe("doctype.nodeValue", "null");
+
+debug("Element creation using createElement on an HTML doc:")
+var element = document.createElement("pre");
+shouldBe("element.nodeName", "'PRE'");
+// Spec: http://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createElement
+// FF returns "PRE" for localName, WebKit returns "pre", the spec says we should return null
+shouldBe("element.localName", "null");
+// FF returns null for namespaceURI, WebKit returns http://www.w3.org/1999/xhtml, the spec says we should return null
+shouldBe("element.namespaceURI", "null");
+shouldBe("element.prefix", "null");
+shouldBe("element.nodeValue", "null");
+shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
+
+debug("Prefixed element creation using createElementNS on an HTML doc:")
+element = document.createElementNS("http://www.w3.org/1999/xhtml", "html:pre");
+shouldBe("element.nodeName", "'HTML:PRE'");
+shouldBe("element.localName", "'pre'");
+shouldBe("element.namespaceURI", "'http://www.w3.org/1999/xhtml'");
+shouldBe("element.prefix", "'html'");
+shouldBe("element.nodeValue", "null");
+shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
+
+debug("SVG Element creation using createElementNS on an HTML doc:")
+element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
+shouldBe("element.nodeName", "'svg'");
+shouldBe("element.localName", "'svg'");
+shouldBe("element.namespaceURI", "'http://www.w3.org/2000/svg'");
+shouldBe("element.prefix", "null");
+shouldBe("element.nodeValue", "null");
+shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
+
+debug("Unknown Element creation using createElementNS on an HTML doc:")
+element = document.createElementNS("http://www.webkit.org", "foo:svg");
+shouldBe("element.nodeName", "'foo:svg'");
+shouldBe("element.localName", "'svg'");
+shouldBe("element.namespaceURI", "'http://www.webkit.org'");
+shouldBe("element.prefix", "'foo'");
+shouldBe("element.nodeValue", "null");
+shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
+
+debug("Element creation using createElementNS on an HTML doc:")
+element = document.createElementNS("http://www.w3.org/1999/xhtml", "pre");
+// Spec: http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-104682815 (element.tagName)
+// FF and Opera returns "pre" for nodeName as it is an XHTML element, WebKit returns "PRE".
+shouldBe("element.nodeName", "'pre'");
+shouldBe("element.localName", "'pre'");
+shouldBe("element.namespaceURI", "'http://www.w3.org/1999/xhtml'");
+shouldBe("element.prefix", "null");
+shouldBe("element.nodeValue", "null");
+shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
+
+debug("Element creation using createElement on an XHTML doc:")
+element = xmlDoc.createElement("pre");
+shouldBe("element.nodeName", "'pre'");
+shouldBe("element.localName", "null");
+// FF returns null for namespaceURI, WebKit returns http://www.w3.org/1999/xhtml, the spec says we should return null
+shouldBe("element.namespaceURI", "null");
+shouldBe("element.prefix", "null");
+shouldBe("element.nodeValue", "null");
+shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
+
+debug("Element creation using createElementNS on an XHTML doc:")
+element = xmlDoc.createElementNS("http://www.w3.org/1999/xhtml", "html:pre");
+shouldBe("element.nodeName", "'html:pre'");
+shouldBe("element.localName", "'pre'");
+shouldBe("element.namespaceURI", "'http://www.w3.org/1999/xhtml'");
+shouldBe("element.prefix", "'html'");
+shouldBe("element.nodeValue", "null");
+shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
+
+debug("Processing instruction creation using createProcessingInstruction on an HTML doc:")
+var processingInstruction = document.createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="missing.xsl"');
+shouldBe("processingInstruction.nodeName", "'xml-stylesheet'");
+shouldBe("processingInstruction.localName", "undefined");
+shouldBe("processingInstruction.namespaceURI", "undefined");
+// DOM Core Level 2 and DOM Core Level 3 disagree on ProcessingInstruction.nodeValue
+// L2: entire content excluding the target
+// L3: same as ProcessingInstruction.data
+// We're following Level 3
+shouldBe("processingInstruction.nodeValue", "'type=\"text/xsl\" href=\"missing.xsl\"'");
+shouldBe("processingInstruction.target", "'xml-stylesheet'");
+shouldBe("processingInstruction.data", "'type=\"text/xsl\" href=\"missing.xsl\"'");
+
+debug("Processing instruction creation using createProcessingInstruction on an XHTML doc:")
+processingInstruction = xmlDoc.createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="missing.xsl"');
+shouldBe("processingInstruction.nodeName", "'xml-stylesheet'");
+shouldBe("processingInstruction.localName", "undefined");
+shouldBe("processingInstruction.namespaceURI", "undefined");
+shouldBe("processingInstruction.nodeValue", "'type=\"text/xsl\" href=\"missing.xsl\"'");
+shouldBe("processingInstruction.target", "'xml-stylesheet'");
+shouldBe("processingInstruction.data", "'type=\"text/xsl\" href=\"missing.xsl\"'");
+
+debug("Text node creation using createTextNode on an HTML doc:")
+var text = document.createTextNode("foo");
+shouldBe("text.nodeName", "'#text'");
+shouldBe("text.localName", "undefined");
+shouldBe("text.namespaceURI", "undefined");
+shouldBe("text.nodeValue", "'foo'");
+shouldBe("text.data", "'foo'");
+</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698