Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / imported / web-platform-tests / custom-elements / instantiating-custom-elements / extensions-to-document-interface / create-element-type-extension-is-a-type.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Document.createElement() and Document.createElementNS() create custom element of type, specified by typeExtension argument</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="Let TYPE be typeExtension, or localName if typeExtension is not present">
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">
12 </head>
13 <body>
14 <div id="log"></div>
15 <script>
16 test(function() {
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         var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
23         var customElement = doc.createElement(tagName, name);
24
25         assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
26             'Custom element type should be ' + name);
27     });
28 }, 'Test Document.createElement() creates custom element of type, ' +
29     'specified by typeExtension argument');
30
31
32 test(function() {
33     var doc = newHTMLDocument();
34     HTML5_ELEMENTS.forEach(function(tagName) {
35         var obj = doc.createElement(tagName);
36         var name = 'x-b-' + tagName;
37         var proto = Object.create(obj.constructor.prototype);
38         var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
39         var customElement = doc.createElementNS(HTML_NAMESPACE, tagName, name);
40
41         assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
42             'Custom element type should be ' + name);
43     });
44 }, 'Test Document.createElementNS() creates custom element of type, ' +
45     'specified by typeExtension argument');
46 </script>
47 </body>
48 </html>