Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / w3c / web-platform-tests / custom-elements / instantiating-custom-elements / custom-element-type-is-attribute.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Instantiation of custom element: custom element type is given as the value of the IS attribute</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
7 <meta name="assert" content="The custom element type is given to a custom element at the time of its instantation in one of the two ways: ... 2. As the value of the IS attribute of the custom element.">
8 <link rel="help" href="http://www.w3.org/TR/custom-elements/#instantiating-custom-elements">
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     HTML5_ELEMENTS.forEach(function(tagName) {
20         if (HTML5_DOCUMENT_ELEMENTS.indexOf(tagName) !== -1) {
21             return;
22         }
23         var obj = doc.createElement(tagName);
24         var name = 'x-a-' + tagName;
25         var proto = Object.create(obj.constructor.prototype);
26         var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
27
28         if (HTML5_TABLE_ELEMENTS.indexOf(tagName) !== -1) {
29             doc.body.innerHTML =
30                 '<table>' +
31                 '<' + tagName + ' id="custom-element" is="' + name + '"></' + tagName + '>' +
32                 '</table>';
33         } else {
34             doc.body.innerHTML =
35                 '<' + tagName + ' id="custom-element" is="' + name + '"></' + tagName + '>';
36         }
37         var customElement = doc.querySelector('#custom-element');
38         assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
39             'Custom element type should be the type, specified as value of IS attribute');
40     });
41 }, 'Instantiation of custom element: custom element type is given as the value of ' +
42     'the IS attribute');
43
44
45 test(function() {
46     var doc = newHTMLDocument();
47     HTML5_ELEMENTS.forEach(function(tagName) {
48         if (HTML5_DOCUMENT_ELEMENTS.indexOf(tagName) !== -1) {
49             return;
50         }
51         var obj = doc.createElement(tagName);
52         var name = 'x-b-' + tagName;
53         if (HTML5_TABLE_ELEMENTS.indexOf(tagName) !== -1) {
54             doc.body.innerHTML =
55                 '<table>' +
56                 '<' + tagName + ' id="custom-element" is="' + name + '"></' + tagName + '>' +
57                 '</table>';
58         } else {
59             doc.body.innerHTML =
60                 '<' + tagName + ' id="custom-element" is="' + name + '"></' + tagName + '>';
61         }
62         var proto = Object.create(obj.constructor.prototype);
63         var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
64
65         var customElement = doc.querySelector('#custom-element');
66
67         assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
68             'Custom element type should be the type, specified as value of IS attribute');
69     });
70 }, 'Instantiation of custom element: custom element type is given as the value ' +
71     'of the IS attribute. Custom element is unresolved at first');
72 </script>
73 </body>
74 </html>