2 <script src=
"../../../resources/testharness.js"></script>
3 <script src=
"../../../resources/testharnessreport.js"></script>
6 function createRegisterParameters() {
8 prototype: Object
.create(HTMLElement
.prototype, { thisIsPrototype
: { value
: true } })
18 // hyphen-containing names from the applicable specifications,
19 // namely the SVG and the MathML.
21 // names containing colon
26 for (var i
= 0; i
< invalidNames
.length
; i
++) {
27 var invalidName
= invalidNames
[i
];
28 assert_throws('SYNTAX_ERR', function (){
29 document
.registerElement(invalidName
, createRegisterParameters());
30 }, 'register invalid custom element name: ' + invalidName
);
33 }, 'invalid and reserved names');
36 document
.registerElement('x-foo', createRegisterParameters());
37 assert_throws('NOT_SUPPORTED_ERR', function (){
38 document
.registerElement('x-foo', createRegisterParameters());
39 }, 'register already registered "x-foo"');
40 assert_throws('NOT_SUPPORTED_ERR', function (){
41 document
.registerElement('X-FOO', createRegisterParameters());
42 }, 'register "X-FOO", same as already registered "x-foo"');
46 var validNameTagMap
= {
52 for(var elementName
in validNameTagMap
) {
53 var expectedTagName
= validNameTagMap
[elementName
];
54 var tagName
= (new (document
.registerElement(elementName
, createRegisterParameters()))()).tagName
;
55 assert_equals(tagName
, expectedTagName
, tagName
+ ' must be treated as a custom element');
57 }, 'strange but valid names');