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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/DOMImplementation-createDocument.html

Issue 1988983002: Move the dom directory from web-platform-tests/ to wpt/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 <!doctype html>
2 <meta charset=utf-8>
3 <title>DOMImplementation.createDocument(namespace, qualifiedName, doctype)</titl e>
4 <link rel=help href="https://dom.spec.whatwg.org/#dom-domimplementation-createdo cument">
5 <link rel=help href="https://dom.spec.whatwg.org/#dom-document-createelementns">
6 <link rel=help href="https://dom.spec.whatwg.org/#dom-node-nodetype">
7 <link rel=help href="https://dom.spec.whatwg.org/#dom-document-documentelement">
8 <link rel=help href="https://dom.spec.whatwg.org/#dom-document-doctype">
9 <script src="../../../../resources/testharness.js"></script>
10 <script src="../../../../resources/testharnessreport.js"></script>
11 <script src="Document-createElementNS.js"></script>
12 <div id="log"></div>
13 <script>
14 var htmlNamespace = "http://www.w3.org/1999/xhtml"
15 var svgNamespace = "http://www.w3.org/2000/svg"
16 var mathMLNamespace = "http://www.w3.org/1998/Math/MathML"
17
18 test(function() {
19 var tests = createElementNS_tests.map(function(t) {
20 return [t[0], t[1], null, t[2]]
21 }).concat([
22 /* Arrays with four elements:
23 * the namespace argument
24 * the qualifiedName argument
25 * the doctype argument
26 * the expected exception, or null if none
27 */
28 [null, null, false, new TypeError()],
29 [null, null, null, null],
30 [null, "", null, null],
31 [undefined, null, undefined, null],
32 [undefined, undefined, undefined, null],
33 [undefined, "", undefined, null],
34 ["http://example.com/", null, null, null],
35 ["http://example.com/", "", null, null],
36 ["/", null, null, null],
37 ["/", "", null, null],
38 ["http://www.w3.org/XML/1998/namespace", null, null, null],
39 ["http://www.w3.org/XML/1998/namespace", "", null, null],
40 ["http://www.w3.org/2000/xmlns/", null, null, null],
41 ["http://www.w3.org/2000/xmlns/", "", null, null],
42 ["foo:", null, null, null],
43 ["foo:", "", null, null],
44 [null, null, document.implementation.createDocumentType("foo", "", ""), null ],
45 [null, null, document.doctype, null], // This causes a horrible WebKit bug ( now fixed in trunk).
46 [null, null, function() {
47 var foo = document.implementation.createDocumentType("foo", "", "");
48 document.implementation.createDocument(null, null, foo);
49 return foo;
50 }(), null], // DOCTYPE already associated with a document.
51 [null, null, function() {
52 var bar = document.implementation.createDocument(null, null, null);
53 return bar.implementation.createDocumentType("bar", "", "");
54 }(), null], // DOCTYPE created by a different implementation.
55 [null, null, function() {
56 var bar = document.implementation.createDocument(null, null, null);
57 var magic = bar.implementation.createDocumentType("bar", "", "");
58 bar.implementation.createDocument(null, null, magic);
59 return magic;
60 }(), null], // DOCTYPE created by a different implementation and already as sociated with a document.
61 [null, "foo", document.implementation.createDocumentType("foo", "", ""), nul l],
62 ["foo", null, document.implementation.createDocumentType("foo", "", ""), nul l],
63 ["foo", "bar", document.implementation.createDocumentType("foo", "", ""), nu ll],
64 [htmlNamespace, "", null, null],
65 [svgNamespace, "", null, null],
66 [mathMLNamespace, "", null, null],
67 [null, "html", null, null],
68 [null, "svg", null, null],
69 [null, "math", null, null],
70 [null, "", document.implementation.createDocumentType("html",
71 "-//W3C//DTD XHTML 1.0 Transitional//EN",
72 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")],
73 [null, "", document.implementation.createDocumentType("svg",
74 "-//W3C//DTD SVG 1.1//EN",
75 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd")],
76 [null, "", document.implementation.createDocumentType("math",
77 "-//W3C//DTD MathML 2.0//EN",
78 "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd")],
79 ])
80
81 tests.forEach(function(t, i) {
82 var namespace = t[0], qualifiedName = t[1], doctype = t[2], expected = t[3]
83 test(function() {
84 if (expected != null) {
85 assert_throws(expected, function() { document.implementation.createDocum ent(namespace, qualifiedName, doctype) })
86 } else {
87 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype)
88 assert_equals(doc.nodeType, Node.DOCUMENT_NODE)
89 assert_equals(doc.nodeType, doc.DOCUMENT_NODE)
90 assert_equals(doc.nodeName, "#document")
91 assert_equals(doc.nodeValue, null)
92 assert_equals(Object.getPrototypeOf(doc), XMLDocument.prototype)
93 var omitRootElement = qualifiedName === null || String(qualifiedName) == = ""
94 if (omitRootElement) {
95 assert_equals(doc.documentElement, null)
96 } else {
97 var element = doc.documentElement
98 assert_not_equals(element, null)
99 assert_equals(element.nodeType, Node.ELEMENT_NODE)
100 assert_equals(element.ownerDocument, doc)
101 var qualified = String(qualifiedName), names = []
102 if (qualified.indexOf(":") >= 0) {
103 names = qualified.split(":", 2)
104 } else {
105 names = [null, qualified]
106 }
107 assert_equals(element.prefix, names[0])
108 assert_equals(element.localName, names[1])
109 assert_equals(element.namespaceURI, namespace === undefined ? null : n amespace)
110 }
111 if (!doctype) {
112 assert_equals(doc.doctype, null)
113 } else {
114 assert_equals(doc.doctype, doctype)
115 assert_equals(doc.doctype.ownerDocument, doc)
116 }
117 assert_equals(doc.childNodes.length, !omitRootElement + !!doctype)
118 }
119 }, "createDocument test " + i + ": " + t.map(function(el) { return format_va lue(el) }))
120
121 if (expected === null) {
122 test(function() {
123 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype)
124 assert_equals(doc.compatMode, "CSS1Compat")
125 assert_equals(doc.characterSet, "UTF-8")
126 assert_equals(doc.contentType, namespace == htmlNamespace ? "application /xhtml+xml"
127 : namespace == svgNamespace ? "image/svg+xml"
128 : "application/xml")
129 assert_equals(doc.URL, "about:blank")
130 assert_equals(doc.documentURI, "about:blank")
131 assert_equals(doc.createElement("DIV").localName, "DIV");
132 }, "createDocument test " + i + ": metadata for " +
133 [namespace, qualifiedName, doctype].map(function(el) { return format_value (el) }))
134
135 test(function() {
136 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype)
137 assert_equals(doc.characterSet, "UTF-8", "characterSet");
138 assert_equals(doc.charset, "UTF-8", "charset");
139 assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
140 }, "createDocument test " + i + ": characterSet aliases for " +
141 [namespace, qualifiedName, doctype].map(function(el) { return format_value (el) }))
142 }
143 })
144 })
145
146 test(function() {
147 assert_throws(new TypeError(), function() {
148 document.implementation.createDocument()
149 }, "createDocument() should throw")
150
151 assert_throws(new TypeError(), function() {
152 document.implementation.createDocument('')
153 }, "createDocument('') should throw")
154 }, "createDocument with missing arguments");
155 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698