Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / w3c / web-platform-tests / custom-elements / registering-custom-elements / definition-construction-algorithm-duplicate-definition.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Check duplicate definition</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="If there already exists a definition with the same TYPE, set ERROR to DuplicateDefinition and stop">
7 <link rel="help" href="http://www.w3.org/TR/custom-elements/#registering-custom-elements">
8 <script src="../../../../resources/testharness.js"></script>
9 <script src="../../../../resources/testharnessreport.js"></script>
10 <script src="../testcommon.js"></script>
11 <link rel="stylesheet" href="../../../../resources/testharness.css">
12 </head>
13 <body>
14 <div id="log"></div>
15 <script>
16 test(function() {
17     var doc = newHTMLDocument();
18     var name = 'x-a';
19     doc.registerElement(name);
20     assert_throws('NotSupportedError', function() {
21         doc.registerElement(name);
22     }, 'Exception should be thrown if definition with the same type already exists');
23 }, 'Check duplicate definition');
24
25
26 test(function() {
27     var doc = newHTMLDocument();
28     var name = 'x-b';
29     doc.registerElement(name);
30     HTML5_ELEMENTS.forEach(function(tagName) {
31         assert_throws('NotSupportedError', function() {
32             doc.registerElement(name, {
33                 extends: tagName
34             });
35         }, 'Exception should be thrown if definition with the same type already exists');
36     });
37 }, 'Check duplicate definition. Specify constructor');
38
39
40 test(function() {
41     var doc = newHTMLDocument();
42     var name = 'x-c';
43     doc.registerElement(name, {
44         prototype: Object.create(HTMLAnchorElement.prototype),
45         extends: 'a'
46     });
47     HTML5_ELEMENTS.forEach(function(tagName) {
48         assert_throws('NotSupportedError', function() {
49             doc.registerElement(name, {
50                 extends: tagName
51             });
52         }, 'Exception should be thrown if definition with the same type already exists');
53     });
54 }, 'Check duplicate definition. Test different prototypes and extends');
55 </script>
56 </body>
57 </html>