4 <title>Document.createElement() and Document.createElementNS() set IS attribute to type</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="If TYPE is not the same as localName, set the value of ELEMENT's IS attribute to TYPE">
7 <link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate">
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">
17 var doc = newHTMLDocument();
18 HTML5_ELEMENTS.forEach(function(tagName) {
19 var obj = doc.createElement(tagName);
20 var name = 'x-a-' + tagName;
21 var proto = Object.create(obj.constructor.prototype);
22 doc.registerElement(name, {prototype: proto, extends: tagName});
23 var customElement = doc.createElement(tagName, name);
24 assert_equals(customElement.getAttribute('is'), name,
25 'Value of the IS attribute should be set to type by Document.createElement()');
27 }, 'Test Document.createElement() sets the element\'s IS attribute value to type, ' +
28 'if type is not the same as localName');
32 var doc = newHTMLDocument();
33 HTML5_ELEMENTS.forEach(function(tagName) {
34 var name = 'x-b-' + tagName;
35 var customElement = doc.createElement(tagName, name);
36 assert_equals(customElement.getAttribute('is'), name,
37 'Value of the IS attribute should be set to type by Document.createElement()');
39 }, 'Test Document.createElement() sets the element\'s IS attribute value to type, ' +
40 'if type is not the same as localName and an element definition with matching ' +
41 'localName, namespace, and type is not registered');
45 var doc = newHTMLDocument();
46 HTML5_ELEMENTS.forEach(function(tagName) {
47 var obj = doc.createElement(tagName);
48 var name = 'x-c-' + tagName;
49 var proto = Object.create(obj.constructor.prototype);
50 doc.registerElement(name, {prototype: proto, extends: tagName});
51 var customElement = doc.createElementNS(HTML_NAMESPACE, tagName, name);
52 assert_equals(customElement.getAttribute('is'), name,
53 'Value of the IS attribute should be set to type by Document.createElementNS()');
55 }, 'Test Document.createElementNS() sets the element\'s IS attribute value to type, ' +
56 'if type is not the same as localName');
60 var doc = newHTMLDocument();
61 HTML5_ELEMENTS.forEach(function(tagName) {
62 var name = 'x-d-' + tagName;
63 var customElement = doc.createElementNS(HTML_NAMESPACE, tagName, name);
64 assert_equals(customElement.getAttribute('is'), name,
65 'Value of the IS attribute should be set to type by Document.createElementNS()');
67 }, 'Test Document.createElementNS() sets the element\'s IS attribute value to type, ' +
68 'if type is not the same as localNameand and an element definition with matching ' +
69 'localName, namespace, and type is not registered ');