4 <title>The custom element type is a sequence of characters that must match the NCName production and contain a minus character</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="The custom element type is a sequence of characters that must match the NCName production and contain a U+002D HYPHEN-MINUS character">
7 <link rel="help" href="https://dvcs.w3.org/hg/webcomponents/raw-file/default/spec/custom/index.html#concepts">
8 <link rel="help" href="http://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-NCName">
9 <script src="../../../../resources/testharness.js"></script>
10 <script src="../../../../resources/testharnessreport.js"></script>
11 <script src="../testcommon.js"></script>
12 <link rel="stylesheet" href="../../../../resources/testharness.css">
18 var doc = newHTMLDocument();
19 var validNames = ['x-frame', 'xx-frame', 'x--frame', '_-frame', 'x-', 'x--',
20 'x-1', 'x-_', '_-_', '__-', '_-1', '_-..'];
21 HTML5_ELEMENTS.forEach(function(value) {
22 validNames.push('x-' + value);
23 validNames.push('Y-' + value.toUpperCase());
25 validNames.forEach(function(value) {
27 doc.registerElement(value);
29 assert_unreached('Exception should not be thrown in case of attempt ' +
30 'to register a custom element with a name \'' + value + '\'');
33 }, 'Registering valid custom element types');
36 var doc = newHTMLDocument();
37 var invalidNames = ['xframe', 'x_frame', 'x.frame', 'x1frame', '-xframe', '1-frame',
38 '1x-frame', '.-frame', '_frame', 'x-f!rame', 'x-:frame'];
39 invalidNames.forEach(function(value) {
40 assert_throws('SyntaxError', function() {
41 doc.registerElement(value);
42 }, 'Exception should be thrown in case of attempt to register element ' +
43 'with the name \'' + value + '\'');
45 }, 'Registering invalid custom element types should fail');
48 var doc = newHTMLDocument();
49 var forbiddenNames = ['annotation-xml',
57 forbiddenNames.forEach(function(value) {
58 assert_throws('SyntaxError', function() {
59 doc.registerElement(value);
60 }, 'Exception should be thrown in case of attempt to register element ' +
61 'with the name \'' + value + '\'');
63 }, 'Registering forbidden custom element types should fail');