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

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

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years 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 test(function() {
15 var tests = createElementNS_tests.map(function(t) {
16 return [t[0], t[1], null, t[2]]
17 }).concat([
18 /* Arrays with four elements:
19 * the namespace argument
20 * the qualifiedName argument
21 * the doctype argument
22 * the expected exception, or null if none
23 */
24 [null, null, false, new TypeError()],
25 [null, null, null, null],
26 [null, "", null, null],
27 [undefined, null, undefined, null],
28 [undefined, undefined, undefined, null],
29 [undefined, "", undefined, null],
30 ["http://example.com/", null, null, null],
31 ["http://example.com/", "", null, null],
32 ["/", null, null, null],
33 ["/", "", null, null],
34 ["http://www.w3.org/XML/1998/namespace", null, null, null],
35 ["http://www.w3.org/XML/1998/namespace", "", null, null],
36 ["http://www.w3.org/2000/xmlns/", null, null, null],
37 ["http://www.w3.org/2000/xmlns/", "", null, null],
38 ["foo:", null, null, null],
39 ["foo:", "", null, null],
40 [null, null, document.implementation.createDocumentType("foo", "", ""), null ],
41 [null, null, document.doctype, null], // This causes a horrible WebKit bug ( now fixed in trunk).
42 [null, null, function() {
43 var foo = document.implementation.createDocumentType("foo", "", "");
44 document.implementation.createDocument(null, null, foo);
45 return foo;
46 }(), null], // DOCTYPE already associated with a document.
47 [null, null, function() {
48 var bar = document.implementation.createDocument(null, null, null);
49 return bar.implementation.createDocumentType("bar", "", "");
50 }(), null], // DOCTYPE created by a different implementation.
51 [null, null, function() {
52 var bar = document.implementation.createDocument(null, null, null);
53 var magic = bar.implementation.createDocumentType("bar", "", "");
54 bar.implementation.createDocument(null, null, magic);
55 return magic;
56 }(), null], // DOCTYPE created by a different implementation and already as sociated with a document.
57 [null, "foo", document.implementation.createDocumentType("foo", "", ""), nul l],
58 ["foo", null, document.implementation.createDocumentType("foo", "", ""), nul l],
59 ["foo", "bar", document.implementation.createDocumentType("foo", "", ""), nu ll],
60 ])
61
62 tests.forEach(function(t, i) {
63 var namespace = t[0], qualifiedName = t[1], doctype = t[2], expected = t[3]
64 test(function() {
65 if (expected != null) {
66 assert_throws(expected, function() { document.implementation.createDocum ent(namespace, qualifiedName, doctype) })
67 } else {
68 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype)
69 assert_equals(doc.nodeType, Node.DOCUMENT_NODE)
70 assert_equals(doc.nodeType, doc.DOCUMENT_NODE)
71 assert_equals(doc.nodeName, "#document")
72 assert_equals(doc.nodeValue, null)
73 var omitRootElement = qualifiedName === null || String(qualifiedName) == = ""
74 if (omitRootElement) {
75 assert_equals(doc.documentElement, null)
76 } else {
77 var element = doc.documentElement
78 assert_not_equals(element, null)
79 assert_equals(element.nodeType, Node.ELEMENT_NODE)
80 assert_equals(element.ownerDocument, doc)
81 var qualified = String(qualifiedName), names = []
82 if (qualified.indexOf(":") >= 0) {
83 names = qualified.split(":", 2)
84 } else {
85 names = [null, qualified]
86 }
87 assert_equals(element.prefix, names[0])
88 assert_equals(element.localName, names[1])
89 assert_equals(element.namespaceURI, namespace === undefined ? null : n amespace)
90 }
91 if (!doctype) {
92 assert_equals(doc.doctype, null)
93 } else {
94 assert_equals(doc.doctype, doctype)
95 assert_equals(doc.doctype.ownerDocument, doc)
96 }
97 assert_equals(doc.childNodes.length, !omitRootElement + !!doctype)
98 }
99 }, "createDocument test " + i + ": " + t.map(function(el) { return format_va lue(el) }))
100
101 if (expected === null) {
102 test(function() {
103 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype)
104 assert_equals(doc.compatMode, "CSS1Compat")
105 assert_equals(doc.characterSet, "UTF-8")
106 assert_equals(doc.contentType, "application/xml")
107 assert_equals(doc.URL, "about:blank")
108 assert_equals(doc.documentURI, "about:blank")
109 assert_equals(doc.createElement("DIV").localName, "DIV");
110 }, "createDocument test " + i + ": metadata for " +
111 [namespace, qualifiedName, doctype].map(function(el) { return format_value (el) }))
112
113 test(function() {
114 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype)
115 assert_equals(doc.characterSet, "UTF-8", "characterSet");
116 assert_equals(doc.charset, "UTF-8", "charset");
117 assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
118 }, "createDocument test " + i + ": characterSet aliases for " +
119 [namespace, qualifiedName, doctype].map(function(el) { return format_value (el) }))
120 }
121 })
122 })
123 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698