Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / w3c / web-platform-tests / custom-elements / concepts / custom-elements-type-naming.html
1 <!DOCTYPE html>
2 <html>
3 <head>
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">
13 </head>
14 <body>
15 <div id="log"></div>
16 <script>
17 test(function() {
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());
24     });
25     validNames.forEach(function(value) {
26         try {
27             doc.registerElement(value);
28         } catch (e) {
29             assert_unreached('Exception should not be thrown in case of attempt ' +
30                 'to register a custom element with a name \'' + value + '\'');
31         }
32     });
33 }, 'Registering valid custom element types');
34
35 test(function() {
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 + '\'');
44     });
45 }, 'Registering invalid custom element types should fail');
46
47 test(function() {
48     var doc = newHTMLDocument();
49     var forbiddenNames = ['annotation-xml',
50                         'color-profile',
51                         'font-face',
52                         'font-face-src',
53                         'font-face-uri',
54                         'font-face-format',
55                         'font-face-name',
56                         'missing-glyph'];
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 + '\'');
62     });
63 }, 'Registering forbidden custom element types should fail');
64 </script>
65 </body>
66 </html>