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">
18 var doc = newHTMLDocument();
19 HTML5_ELEMENTS.forEach(function(tagName) {
20 if (HTML5_DOCUMENT_ELEMENTS.indexOf(tagName) !== -1) {
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});
28 if (HTML5_TABLE_ELEMENTS.indexOf(tagName) !== -1) {
31 '<' + tagName + ' id="custom-element" is="' + name + '"></' + tagName + '>' +
35 '<' + tagName + ' id="custom-element" is="' + name + '"></' + tagName + '>';
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');
41 }, 'Instantiation of custom element: custom element type is given as the value of ' +
46 var doc = newHTMLDocument();
47 HTML5_ELEMENTS.forEach(function(tagName) {
48 if (HTML5_DOCUMENT_ELEMENTS.indexOf(tagName) !== -1) {
51 var obj = doc.createElement(tagName);
52 var name = 'x-b-' + tagName;
53 if (HTML5_TABLE_ELEMENTS.indexOf(tagName) !== -1) {
56 '<' + tagName + ' id="custom-element" is="' + name + '"></' + tagName + '>' +
60 '<' + tagName + ' id="custom-element" is="' + name + '"></' + tagName + '>';
62 var proto = Object.create(obj.constructor.prototype);
63 var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
65 var customElement = doc.querySelector('#custom-element');
67 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
68 'Custom element type should be the type, specified as value of IS attribute');
70 }, 'Instantiation of custom element: custom element type is given as the value ' +
71 'of the IS attribute. Custom element is unresolved at first');