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

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

Issue 2323113002: Revert "Import wpt@65954a35b4e0a5cee1f4839271ba0e44f187c0a6" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
1 <!doctype html> 1 <!doctype html>
2 <meta charset=utf-8> 2 <meta charset=utf-8>
3 <title>DOMImplementation.createDocument(namespace, qualifiedName, doctype)</titl e> 3 <title>DOMImplementation.createDocument(namespace, qualifiedName, doctype)</titl e>
4 <link rel=help href="https://dom.spec.whatwg.org/#dom-domimplementation-createdo cument"> 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"> 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"> 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"> 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"> 8 <link rel=help href="https://dom.spec.whatwg.org/#dom-document-doctype">
9 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharness.js"></script>
10 <script src="/resources/testharnessreport.js"></script> 10 <script src="/resources/testharnessreport.js"></script>
11 <script src="Document-createElementNS.js"></script> 11 <script src="Document-createElementNS.js"></script>
12 <div id="log"></div> 12 <div id="log"></div>
13 <script> 13 <script>
14 var htmlNamespace = "http://www.w3.org/1999/xhtml" 14 var htmlNamespace = "http://www.w3.org/1999/xhtml"
15 var svgNamespace = "http://www.w3.org/2000/svg" 15 var svgNamespace = "http://www.w3.org/2000/svg"
16 var mathMLNamespace = "http://www.w3.org/1998/Math/MathML" 16 var mathMLNamespace = "http://www.w3.org/1998/Math/MathML"
17 17
18 // Make DocumentTypes distinct
19 function my_format_value(val) {
20 if (val instanceof DocumentType) {
21 return "DocumentType node <!DOCTYPE " + val.name
22 + (val.publicId ? " " + val.publicId : "")
23 + (val.systemId ? " " + val.systemId : "")
24 + ">";
25 }
26 return format_value(val);
27 }
28
29 test(function() { 18 test(function() {
30 var tests = createElementNS_tests.map(function(t) { 19 var tests = createElementNS_tests.map(function(t) {
31 return [t[0], t[1], null, t[2]] 20 return [t[0], t[1], null, t[2]]
32 }).concat([ 21 }).concat([
33 /* Arrays with four elements: 22 /* Arrays with four elements:
34 * the namespace argument 23 * the namespace argument
35 * the qualifiedName argument 24 * the qualifiedName argument
36 * the doctype argument 25 * the doctype argument
37 * the expected exception, or null if none 26 * the expected exception, or null if none
38 */ 27 */
39 [null, null, false, new TypeError()], 28 [null, null, false, new TypeError()],
40 [null, null, null, null], 29 [null, null, null, null],
41 [null, "", null, null], 30 [null, "", null, null],
42 [undefined, null, undefined, null], 31 [undefined, null, undefined, null],
43 [undefined, undefined, undefined, null], 32 [undefined, undefined, undefined, null],
44 [undefined, "", undefined, null], 33 [undefined, "", undefined, null],
45 ["http://example.com/", null, null, null], 34 ["http://example.com/", null, null, null],
46 ["http://example.com/", "", null, null], 35 ["http://example.com/", "", null, null],
47 ["/", null, null, null], 36 ["/", null, null, null],
48 ["/", "", null, null], 37 ["/", "", null, null],
49 ["http://www.w3.org/XML/1998/namespace", null, null, null], 38 ["http://www.w3.org/XML/1998/namespace", null, null, null],
50 ["http://www.w3.org/XML/1998/namespace", "", null, null], 39 ["http://www.w3.org/XML/1998/namespace", "", null, null],
51 ["http://www.w3.org/2000/xmlns/", null, null, null], 40 ["http://www.w3.org/2000/xmlns/", null, null, null],
52 ["http://www.w3.org/2000/xmlns/", "", null, null], 41 ["http://www.w3.org/2000/xmlns/", "", null, null],
53 ["foo:", null, null, null], 42 ["foo:", null, null, null],
54 ["foo:", "", null, null], 43 ["foo:", "", null, null],
55 [null, null, document.implementation.createDocumentType("foo", "", ""), null ], 44 [null, null, document.implementation.createDocumentType("foo", "", ""), null ],
56 [null, null, document.doctype, null], // This causes a horrible WebKit bug ( now fixed in trunk). 45 [null, null, document.doctype, null], // This causes a horrible WebKit bug ( now fixed in trunk).
57 [null, null, function() { 46 [null, null, function() {
58 var foo = document.implementation.createDocumentType("bar", "", ""); 47 var foo = document.implementation.createDocumentType("foo", "", "");
59 document.implementation.createDocument(null, null, foo); 48 document.implementation.createDocument(null, null, foo);
60 return foo; 49 return foo;
61 }(), null], // DOCTYPE already associated with a document. 50 }(), null], // DOCTYPE already associated with a document.
62 [null, null, function() { 51 [null, null, function() {
63 var bar = document.implementation.createDocument(null, null, null); 52 var bar = document.implementation.createDocument(null, null, null);
64 return bar.implementation.createDocumentType("baz", "", ""); 53 return bar.implementation.createDocumentType("bar", "", "");
65 }(), null], // DOCTYPE created by a different implementation. 54 }(), null], // DOCTYPE created by a different implementation.
66 [null, null, function() { 55 [null, null, function() {
67 var bar = document.implementation.createDocument(null, null, null); 56 var bar = document.implementation.createDocument(null, null, null);
68 var magic = bar.implementation.createDocumentType("quz", "", ""); 57 var magic = bar.implementation.createDocumentType("bar", "", "");
69 bar.implementation.createDocument(null, null, magic); 58 bar.implementation.createDocument(null, null, magic);
70 return magic; 59 return magic;
71 }(), null], // DOCTYPE created by a different implementation and already as sociated with a document. 60 }(), null], // DOCTYPE created by a different implementation and already as sociated with a document.
72 [null, "foo", document.implementation.createDocumentType("foo", "", ""), nul l], 61 [null, "foo", document.implementation.createDocumentType("foo", "", ""), nul l],
73 ["foo", null, document.implementation.createDocumentType("foo", "", ""), nul l], 62 ["foo", null, document.implementation.createDocumentType("foo", "", ""), nul l],
74 ["foo", "bar", document.implementation.createDocumentType("foo", "", ""), nu ll], 63 ["foo", "bar", document.implementation.createDocumentType("foo", "", ""), nu ll],
75 [htmlNamespace, "", null, null], 64 [htmlNamespace, "", null, null],
76 [svgNamespace, "", null, null], 65 [svgNamespace, "", null, null],
77 [mathMLNamespace, "", null, null], 66 [mathMLNamespace, "", null, null],
78 [null, "html", null, null], 67 [null, "html", null, null],
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 assert_equals(element.namespaceURI, namespace === undefined ? null : n amespace) 109 assert_equals(element.namespaceURI, namespace === undefined ? null : n amespace)
121 } 110 }
122 if (!doctype) { 111 if (!doctype) {
123 assert_equals(doc.doctype, null) 112 assert_equals(doc.doctype, null)
124 } else { 113 } else {
125 assert_equals(doc.doctype, doctype) 114 assert_equals(doc.doctype, doctype)
126 assert_equals(doc.doctype.ownerDocument, doc) 115 assert_equals(doc.doctype.ownerDocument, doc)
127 } 116 }
128 assert_equals(doc.childNodes.length, !omitRootElement + !!doctype) 117 assert_equals(doc.childNodes.length, !omitRootElement + !!doctype)
129 } 118 }
130 }, "createDocument test: " + t.map(my_format_value)) 119 }, "createDocument test " + i + ": " + t.map(function(el) { return format_va lue(el) }))
131 120
132 if (expected === null) { 121 if (expected === null) {
133 test(function() { 122 test(function() {
134 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype) 123 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype)
135 assert_equals(doc.compatMode, "CSS1Compat") 124 assert_equals(doc.compatMode, "CSS1Compat")
136 assert_equals(doc.characterSet, "UTF-8") 125 assert_equals(doc.characterSet, "UTF-8")
137 assert_equals(doc.contentType, namespace == htmlNamespace ? "application /xhtml+xml" 126 assert_equals(doc.contentType, namespace == htmlNamespace ? "application /xhtml+xml"
138 : namespace == svgNamespace ? "image/svg+xml" 127 : namespace == svgNamespace ? "image/svg+xml"
139 : "application/xml") 128 : "application/xml")
140 assert_equals(doc.URL, "about:blank") 129 assert_equals(doc.URL, "about:blank")
141 assert_equals(doc.documentURI, "about:blank") 130 assert_equals(doc.documentURI, "about:blank")
142 assert_equals(doc.createElement("DIV").localName, "DIV"); 131 assert_equals(doc.createElement("DIV").localName, "DIV");
143 }, "createDocument test " + i + ": metadata for " + 132 }, "createDocument test " + i + ": metadata for " +
144 [namespace, qualifiedName, doctype].map(my_format_value)) 133 [namespace, qualifiedName, doctype].map(function(el) { return format_value (el) }))
145 134
146 test(function() { 135 test(function() {
147 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype) 136 var doc = document.implementation.createDocument(namespace, qualifiedNam e, doctype)
148 assert_equals(doc.characterSet, "UTF-8", "characterSet"); 137 assert_equals(doc.characterSet, "UTF-8", "characterSet");
149 assert_equals(doc.charset, "UTF-8", "charset"); 138 assert_equals(doc.charset, "UTF-8", "charset");
150 assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding"); 139 assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
151 }, "createDocument test " + i + ": characterSet aliases for " + 140 }, "createDocument test " + i + ": characterSet aliases for " +
152 [namespace, qualifiedName, doctype].map(my_format_value)) 141 [namespace, qualifiedName, doctype].map(function(el) { return format_value (el) }))
153 } 142 }
154 }) 143 })
155 }) 144 })
156 145
157 test(function() { 146 test(function() {
158 assert_throws(new TypeError(), function() { 147 assert_throws(new TypeError(), function() {
159 document.implementation.createDocument() 148 document.implementation.createDocument()
160 }, "createDocument() should throw") 149 }, "createDocument() should throw")
161 150
162 assert_throws(new TypeError(), function() { 151 assert_throws(new TypeError(), function() {
163 document.implementation.createDocument('') 152 document.implementation.createDocument('')
164 }, "createDocument('') should throw") 153 }, "createDocument('') should throw")
165 }, "createDocument with missing arguments"); 154 }, "createDocument with missing arguments");
166 </script> 155 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698