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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Node/script-tests/initial-values.js

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 description("Test creation of each type of Node and check initial values")
2
3 var xmlDoc = document.implementation.createDocument("http://www.w3.org/1999/xhtm l", "html", null);
4
5 debug("Attribute creation using createElement on an HTML doc:")
6 var attr = document.createAttribute("foo");
7 shouldBe("attr.nodeName", "'foo'");
8 shouldBe("attr.name", "'foo'");
9 // Spec: http://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-create Attribute
10 // Both FF and WebKit return "foo" for Attribute.localName, even though the spec says null
11 shouldBe("attr.localName", "null");
12 shouldBe("attr.namespaceURI", "null");
13 shouldBe("attr.prefix", "null");
14 shouldBe("attr.value", "''");
15
16 debug("Attribute creation using createElementNS on an HTML doc:")
17 attr = document.createAttributeNS("http://www.example.com", "example:foo");
18 shouldBe("attr.nodeName", "'example:foo'");
19 shouldBe("attr.name", "'example:foo'");
20 shouldBe("attr.localName", "'foo'");
21 shouldBe("attr.namespaceURI", "'http://www.example.com'");
22 shouldBe("attr.prefix", "'example'");
23 shouldBe("attr.nodeValue", "''");
24 shouldBe("attr.value", "''");
25
26 debug("Attribute creation using createElement on an XHTML doc:")
27 attr = xmlDoc.createAttribute("foo");
28 shouldBe("attr.nodeName", "'foo'");
29 shouldBe("attr.name", "'foo'");
30 // Spec: http://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-create Attribute
31 // Both FF and WebKit return "foo" for Attribute.localName, even though the spec says null
32 shouldBe("attr.localName", "null");
33 shouldBe("attr.namespaceURI", "null");
34 shouldBe("attr.prefix", "null");
35 shouldBe("attr.value", "''");
36
37 debug("Attribute creation using createElementNS on an XHTML doc:")
38 attr = xmlDoc.createAttributeNS("http://www.example.com", "example:foo");
39 shouldBe("attr.nodeName", "'example:foo'");
40 shouldBe("attr.name", "'example:foo'");
41 shouldBe("attr.localName", "'foo'");
42 shouldBe("attr.namespaceURI", "'http://www.example.com'");
43 shouldBe("attr.prefix", "'example'");
44 shouldBe("attr.nodeValue", "''");
45 shouldBe("attr.value", "''");
46
47 var comment = document.createComment("foo");
48 shouldBe("comment.nodeName", "'#comment'");
49 shouldBe("comment.localName", "undefined");
50 shouldBe("comment.namespaceURI", "undefined");
51 shouldBe("comment.nodeValue", "'foo'");
52 shouldBe("comment.data", "'foo'");
53
54 shouldThrow("document.createCDATASection('foo')");
55 var cdata = xmlDoc.createCDATASection("foo");
56 shouldBe("cdata.nodeName", "'#cdata-section'");
57 shouldBe("cdata.localName", "undefined");
58 shouldBe("cdata.namespaceURI", "undefined");
59 shouldBe("cdata.nodeValue", "'foo'");
60 shouldBe("cdata.data", "'foo'");
61
62 var fragment = document.createDocumentFragment();
63 shouldBe("fragment.nodeName", "'#document-fragment'");
64 shouldBe("fragment.localName", "undefined");
65 shouldBe("fragment.namespaceURI", "undefined");
66 shouldBe("fragment.nodeValue", "null");
67
68 var doc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
69 shouldBe("doc.nodeName", "'#document'");
70 shouldBe("doc.localName", "undefined");
71 shouldBe("doc.namespaceURI", "undefined");
72 shouldBe("doc.nodeValue", "null");
73
74 var doctype = document.implementation.createDocumentType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd");
75 shouldBe("doctype.nodeName", "'svg'");
76 shouldBe("doctype.name", "'svg'");
77 shouldBe("doctype.localName", "undefined");
78 shouldBe("doctype.namespaceURI", "undefined");
79 shouldBe("doctype.nodeValue", "null");
80
81 debug("Element creation using createElement on an HTML doc:")
82 var element = document.createElement("pre");
83 shouldBe("element.nodeName", "'PRE'");
84 // Spec: http://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-create Element
85 // FF returns "PRE" for localName, WebKit returns "pre", the spec says we should return null
86 shouldBe("element.localName", "null");
87 // FF returns null for namespaceURI, WebKit returns http://www.w3.org/1999/xhtml , the spec says we should return null
88 shouldBe("element.namespaceURI", "null");
89 shouldBe("element.prefix", "null");
90 shouldBe("element.nodeValue", "null");
91 shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
92
93 debug("Prefixed element creation using createElementNS on an HTML doc:")
94 element = document.createElementNS("http://www.w3.org/1999/xhtml", "html:pre");
95 shouldBe("element.nodeName", "'HTML:PRE'");
96 shouldBe("element.localName", "'pre'");
97 shouldBe("element.namespaceURI", "'http://www.w3.org/1999/xhtml'");
98 shouldBe("element.prefix", "'html'");
99 shouldBe("element.nodeValue", "null");
100 shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
101
102 debug("SVG Element creation using createElementNS on an HTML doc:")
103 element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
104 shouldBe("element.nodeName", "'svg'");
105 shouldBe("element.localName", "'svg'");
106 shouldBe("element.namespaceURI", "'http://www.w3.org/2000/svg'");
107 shouldBe("element.prefix", "null");
108 shouldBe("element.nodeValue", "null");
109 shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
110
111 debug("Unknown Element creation using createElementNS on an HTML doc:")
112 element = document.createElementNS("http://www.webkit.org", "foo:svg");
113 shouldBe("element.nodeName", "'foo:svg'");
114 shouldBe("element.localName", "'svg'");
115 shouldBe("element.namespaceURI", "'http://www.webkit.org'");
116 shouldBe("element.prefix", "'foo'");
117 shouldBe("element.nodeValue", "null");
118 shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
119
120 debug("Element creation using createElementNS on an HTML doc:")
121 element = document.createElementNS("http://www.w3.org/1999/xhtml", "pre");
122 // Spec: http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-104682815 (element.t agName)
123 // FF and Opera returns "pre" for nodeName as it is an XHTML element, WebKit ret urns "PRE".
124 shouldBe("element.nodeName", "'pre'");
125 shouldBe("element.localName", "'pre'");
126 shouldBe("element.namespaceURI", "'http://www.w3.org/1999/xhtml'");
127 shouldBe("element.prefix", "null");
128 shouldBe("element.nodeValue", "null");
129 shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
130
131 debug("Element creation using createElement on an XHTML doc:")
132 element = xmlDoc.createElement("pre");
133 shouldBe("element.nodeName", "'pre'");
134 shouldBe("element.localName", "null");
135 // FF returns null for namespaceURI, WebKit returns http://www.w3.org/1999/xhtml , the spec says we should return null
136 shouldBe("element.namespaceURI", "null");
137 shouldBe("element.prefix", "null");
138 shouldBe("element.nodeValue", "null");
139 shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
140
141 debug("Element creation using createElementNS on an XHTML doc:")
142 element = xmlDoc.createElementNS("http://www.w3.org/1999/xhtml", "html:pre");
143 shouldBe("element.nodeName", "'html:pre'");
144 shouldBe("element.localName", "'pre'");
145 shouldBe("element.namespaceURI", "'http://www.w3.org/1999/xhtml'");
146 shouldBe("element.prefix", "'html'");
147 shouldBe("element.nodeValue", "null");
148 shouldBe("element.attributes.toString()", "'[object NamedNodeMap]'");
149
150 debug("Processing instruction creation using createProcessingInstruction on an H TML doc:")
151 var processingInstruction = document.createProcessingInstruction('xml-stylesheet ', 'type="text/xsl" href="missing.xsl"');
152 shouldBe("processingInstruction.nodeName", "'xml-stylesheet'");
153 shouldBe("processingInstruction.localName", "undefined");
154 shouldBe("processingInstruction.namespaceURI", "undefined");
155 // DOM Core Level 2 and DOM Core Level 3 disagree on ProcessingInstruction.nodeV alue
156 // L2: entire content excluding the target
157 // L3: same as ProcessingInstruction.data
158 // We're following Level 3
159 shouldBe("processingInstruction.nodeValue", "'type=\"text/xsl\" href=\"missing.x sl\"'");
160 shouldBe("processingInstruction.target", "'xml-stylesheet'");
161 shouldBe("processingInstruction.data", "'type=\"text/xsl\" href=\"missing.xsl\"' ");
162
163 debug("Processing instruction creation using createProcessingInstruction on an X HTML doc:")
164 processingInstruction = xmlDoc.createProcessingInstruction('xml-stylesheet', 'ty pe="text/xsl" href="missing.xsl"');
165 shouldBe("processingInstruction.nodeName", "'xml-stylesheet'");
166 shouldBe("processingInstruction.localName", "undefined");
167 shouldBe("processingInstruction.namespaceURI", "undefined");
168 shouldBe("processingInstruction.nodeValue", "'type=\"text/xsl\" href=\"missing.x sl\"'");
169 shouldBe("processingInstruction.target", "'xml-stylesheet'");
170 shouldBe("processingInstruction.data", "'type=\"text/xsl\" href=\"missing.xsl\"' ");
171
172 debug("Text node creation using createTextNode on an HTML doc:")
173 var text = document.createTextNode("foo");
174 shouldBe("text.nodeName", "'#text'");
175 shouldBe("text.localName", "undefined");
176 shouldBe("text.namespaceURI", "undefined");
177 shouldBe("text.nodeValue", "'foo'");
178 shouldBe("text.data", "'foo'");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698