| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <meta charset=utf-8> | |
| 3 <title>Document.createElement</title> | |
| 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-document-createelement"> | |
| 5 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-localname"> | |
| 6 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-tagname"> | |
| 7 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-prefix"> | |
| 8 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-namespaceuri"> | |
| 9 <script src="../../../../resources/testharness.js"></script> | |
| 10 <script src="../../../../resources/testharnessreport.js"></script> | |
| 11 <div id="log"></div> | |
| 12 <script> | |
| 13 function toASCIIUppercase(str) { | |
| 14 var diff = "a".charCodeAt(0) - "A".charCodeAt(0); | |
| 15 var res = ""; | |
| 16 for (var i = 0; i < str.length; ++i) { | |
| 17 if ("a" <= str[i] && str[i] <= "z") { | |
| 18 res += String.fromCharCode(str.charCodeAt(i) - diff); | |
| 19 } else { | |
| 20 res += str[i]; | |
| 21 } | |
| 22 } | |
| 23 return res; | |
| 24 } | |
| 25 test(function() { | |
| 26 var HTMLNS = "http://www.w3.org/1999/xhtml", | |
| 27 valid = [ | |
| 28 //[input, localName], | |
| 29 [undefined, "undefined"], | |
| 30 [null, "null"], | |
| 31 ["foo", "foo"], | |
| 32 ["f1oo", "f1oo"], | |
| 33 ["foo1", "foo1"], | |
| 34 ["f\u0300oo", "f\u0300oo"], | |
| 35 ["foo\u0300", "foo\u0300"], | |
| 36 [":foo", ":foo"], | |
| 37 ["f:oo", "f:oo"], | |
| 38 ["foo:", "foo:"], | |
| 39 ["xml", "xml"], | |
| 40 ["xmlns", "xmlns"], | |
| 41 ["xmlfoo", "xmlfoo"], | |
| 42 ["xml:foo", "xml:foo"], | |
| 43 ["xmlns:foo", "xmlns:foo"], | |
| 44 ["xmlfoo:bar", "xmlfoo:bar"], | |
| 45 ["svg", "svg"], | |
| 46 ["math", "math"], | |
| 47 ["FOO", "foo"], | |
| 48 ["mar\u212a", "mar\u212a"], | |
| 49 ["\u0130nput", "\u0130nput"], | |
| 50 ["\u0131nput", "\u0131nput"] | |
| 51 ], | |
| 52 invalid = [ | |
| 53 "", | |
| 54 "1foo", | |
| 55 "\u0300foo", | |
| 56 "}foo", | |
| 57 "f}oo", | |
| 58 "foo}", | |
| 59 "\ufffffoo", | |
| 60 "f\uffffoo", | |
| 61 "foo\uffff", | |
| 62 "<foo", | |
| 63 "foo>", | |
| 64 "<foo>", | |
| 65 "f<oo" | |
| 66 ] | |
| 67 | |
| 68 valid.forEach(function(t) { | |
| 69 test(function() { | |
| 70 var elt = document.createElement(t[0]) | |
| 71 assert_true(elt instanceof Element) | |
| 72 assert_true(elt instanceof Node) | |
| 73 assert_equals(elt.localName, t[1]) | |
| 74 assert_equals(elt.tagName, toASCIIUppercase(t[1])) | |
| 75 assert_equals(elt.prefix, null) | |
| 76 assert_equals(elt.namespaceURI, HTMLNS) | |
| 77 }, "createElement(" + format_value(t[0]) + ")"); | |
| 78 }); | |
| 79 invalid.forEach(function(arg) { | |
| 80 test(function() { | |
| 81 assert_throws("INVALID_CHARACTER_ERR", function() { document.createElement
(arg) }) | |
| 82 }, "createElement(" + format_value(arg) + ")"); | |
| 83 }); | |
| 84 }) | |
| 85 </script> | |
| OLD | NEW |