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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Document-createElementNS.html

Issue 2477133002: Import wpt@306326cfe973b6c7019c50879ad03b02825c7539 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 4 years, 1 month 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>Document.createElementNS</title> 3 <title>Document.createElementNS</title>
4 <link rel=help href="https://dom.spec.whatwg.org/#dom-document-createelementns"> 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-document-createelementns">
5 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/testharnessreport.js"></script>
7 <script src="Document-createElementNS.js"></script> 7 <script src="Document-createElementNS.js"></script>
8 <div id="log"></div> 8 <div id="log"></div>
9 <iframe src="/common/dummy.xml"></iframe>
10 <iframe src="/common/dummy.xhtml"></iframe>
9 <script> 11 <script>
10 test(function() { 12 var tests = createElementNS_tests.concat([
11 var tests = createElementNS_tests.concat([ 13 /* Arrays with three elements:
12 /* Arrays with three elements: 14 * the namespace argument
13 * the namespace argument 15 * the qualifiedName argument
14 * the qualifiedName argument 16 * the expected exception, or null if none
15 * the expected exception, or null if none 17 */
16 */ 18 ["", "", "INVALID_CHARACTER_ERR"],
17 ["", "", "INVALID_CHARACTER_ERR"], 19 [null, null, null],
18 [null, null, null], 20 [null, "", "INVALID_CHARACTER_ERR"],
19 [null, "", "INVALID_CHARACTER_ERR"], 21 [undefined, null, null],
20 [undefined, null, null], 22 [undefined, "", "INVALID_CHARACTER_ERR"],
21 [undefined, "", "INVALID_CHARACTER_ERR"], 23 ["http://example.com/", null, null],
22 ["http://example.com/", null, null], 24 ["http://example.com/", "", "INVALID_CHARACTER_ERR"],
23 ["http://example.com/", "", "INVALID_CHARACTER_ERR"], 25 ["/", null, null],
24 ["/", null, null], 26 ["/", "", "INVALID_CHARACTER_ERR"],
25 ["/", "", "INVALID_CHARACTER_ERR"], 27 ["http://www.w3.org/XML/1998/namespace", null, null],
26 ["http://www.w3.org/XML/1998/namespace", null, null], 28 ["http://www.w3.org/XML/1998/namespace", "", "INVALID_CHARACTER_ERR"],
27 ["http://www.w3.org/XML/1998/namespace", "", "INVALID_CHARACTER_ERR"], 29 ["http://www.w3.org/2000/xmlns/", null, "NAMESPACE_ERR"],
28 ["http://www.w3.org/2000/xmlns/", null, "NAMESPACE_ERR"], 30 ["http://www.w3.org/2000/xmlns/", "", "INVALID_CHARACTER_ERR"],
29 ["http://www.w3.org/2000/xmlns/", "", "INVALID_CHARACTER_ERR"], 31 ["foo:", null, null],
30 ["foo:", null, null], 32 ["foo:", "", "INVALID_CHARACTER_ERR"],
31 ["foo:", "", "INVALID_CHARACTER_ERR"], 33 ])
32 ])
33 34
34 tests.forEach(function(t, i) { 35 var xmlIframe = document.querySelector('[src="/common/dummy.xml"]');
35 test(function() { 36 var xhtmlIframe = document.querySelector('[src="/common/dummy.xhtml"]');
36 var namespace = t[0], qualifiedName = t[1], expected = t[2] 37
37 if (expected != null) { 38 function runTest(t, i, desc) {
38 assert_throws(expected, function() { document.createElementNS(namespace, qualifiedName) }) 39 async_test(function(testObj) {
39 } else { 40 window.addEventListener("load", function() {
40 var element = document.createElementNS(namespace, qualifiedName) 41 testObj.step(function() {
41 assert_not_equals(element, null) 42 var doc;
42 assert_equals(element.nodeType, Node.ELEMENT_NODE) 43 if (desc == "HTML document") {
43 assert_equals(element.nodeType, element.ELEMENT_NODE) 44 doc = document;
44 assert_equals(element.nodeValue, null) 45 } else if (desc == "XML document") {
45 assert_equals(element.ownerDocument, document) 46 doc = xmlIframe.contentDocument;
46 var qualified = String(qualifiedName), names = [] 47 // Make sure we're testing the right document
47 if (qualified.indexOf(":") >= 0) { 48 assert_equals(doc.documentElement.textContent, "Dummy XML document");
48 names = qualified.split(":", 2) 49 } else if (desc == "XHTML document") {
50 doc = xhtmlIframe.contentDocument;
51 assert_equals(doc.documentElement.textContent, "Dummy XHTML document") ;
52 }
53 var namespace = t[0], qualifiedName = t[1], expected = t[2]
54 if (expected != null) {
55 assert_throws(expected, function() { doc.createElementNS(namespace, qu alifiedName) })
49 } else { 56 } else {
50 names = [null, qualified] 57 var element = doc.createElementNS(namespace, qualifiedName)
58 assert_not_equals(element, null)
59 assert_equals(element.nodeType, Node.ELEMENT_NODE)
60 assert_equals(element.nodeType, element.ELEMENT_NODE)
61 assert_equals(element.nodeValue, null)
62 assert_equals(element.ownerDocument, doc)
63 var qualified = String(qualifiedName), names = []
64 if (qualified.indexOf(":") >= 0) {
65 names = qualified.split(":", 2)
66 } else {
67 names = [null, qualified]
68 }
69 assert_equals(element.prefix, names[0])
70 assert_equals(element.localName, names[1])
71 assert_equals(element.tagName, qualified)
72 assert_equals(element.nodeName, qualified)
73 assert_equals(element.namespaceURI,
74 namespace === undefined || namespace === "" ? null
75 : namespace)
51 } 76 }
52 assert_equals(element.prefix, names[0]) 77 });
53 assert_equals(element.localName, names[1]) 78 testObj.done();
54 assert_equals(element.tagName, qualified) 79 });
55 assert_equals(element.nodeName, qualified) 80 }, "createElementNS test in " + desc + ": " + t.map(format_value))
56 assert_equals(element.namespaceURI, namespace === undefined ? null : nam espace) 81 }
57 } 82
58 }, "createElementNS test: " + t.map(format_value)) 83 tests.forEach(function(t, i) {
59 }) 84 runTest(t, i, "HTML document")
85 runTest(t, i, "XML document")
86 runTest(t, i, "XHTML document")
60 }) 87 })
61 88
89
62 test(function() { 90 test(function() {
63 var HTMLNS = "http://www.w3.org/1999/xhtml"; 91 var HTMLNS = "http://www.w3.org/1999/xhtml";
64 var element = document.createElementNS(HTMLNS, "span"); 92 var element = document.createElementNS(HTMLNS, "span");
65 assert_equals(element.namespaceURI, HTMLNS); 93 assert_equals(element.namespaceURI, HTMLNS);
66 assert_equals(element.prefix, null); 94 assert_equals(element.prefix, null);
67 assert_equals(element.localName, "span"); 95 assert_equals(element.localName, "span");
68 assert_equals(element.tagName, "SPAN"); 96 assert_equals(element.tagName, "SPAN");
69 assert_true(element instanceof Node, "Should be a Node"); 97 assert_true(element instanceof Node, "Should be a Node");
70 assert_true(element instanceof Element, "Should be an Element"); 98 assert_true(element instanceof Element, "Should be an Element");
71 assert_true(element instanceof HTMLElement, "Should be an HTMLElement"); 99 assert_true(element instanceof HTMLElement, "Should be an HTMLElement");
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 assert_equals(element.namespaceURI, null); 217 assert_equals(element.namespaceURI, null);
190 assert_equals(element.prefix, null); 218 assert_equals(element.prefix, null);
191 assert_equals(element.localName, "span"); 219 assert_equals(element.localName, "span");
192 assert_equals(element.tagName, "span"); 220 assert_equals(element.tagName, "span");
193 assert_true(element instanceof Node, "Should be a Node"); 221 assert_true(element instanceof Node, "Should be a Node");
194 assert_true(element instanceof Element, "Should be an Element"); 222 assert_true(element instanceof Element, "Should be an Element");
195 assert_false(element instanceof HTMLElement, "Should not be an HTMLElement"); 223 assert_false(element instanceof HTMLElement, "Should not be an HTMLElement");
196 assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanEle ment"); 224 assert_false(element instanceof HTMLSpanElement, "Should not be an HTMLSpanEle ment");
197 }, "empty string namespace"); 225 }, "empty string namespace");
198 </script> 226 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698