4 <title>Custom element constructor sets owner document to the document, where custom element type is registered</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="Custom element constructor sets custom element node document to the document, where custom element type is registered">
7 <link rel="help" href="http://www.w3.org/TR/custom-elements/#instantiating-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">
17 var doc = newHTMLDocument();
18 var GeneratedConstructor = doc.registerElement('x-a');
19 var customElement = new GeneratedConstructor();
20 assert_equals(customElement.ownerDocument, doc,
21 'Custom element owner document should be the document, where custom element ' +
22 'type is registered');
23 }, 'Custom element constructor sets owner document to the document, where custom element ' +
24 'type is registered');
28 var doc = newHTMLDocument();
29 HTML5_ELEMENTS.forEach(function(tagName) {
30 var obj = doc.createElement(tagName);
31 var name = 'x-b-' + tagName;
32 var proto = Object.create(obj.constructor.prototype);
33 var GeneratedConstructor = doc.registerElement(name, {
37 var customElement = new GeneratedConstructor();
39 assert_equals(customElement.ownerDocument, doc,
40 'Custom element owner document should be the document, where custom element ' +
41 'type is registered');
43 }, 'Custom element constructor sets owner document to the document, where custom element ' +
44 'type is registered. Test constructor of extended HTML element');
48 var doc = newHTMLDocument();
49 var sharedRegistryDocument = doc.implementation.createHTMLDocument('Document 2');
52 var GeneratedConstructor = doc.registerElement(name);
53 var customElement = new GeneratedConstructor();
54 assert_equals(customElement.ownerDocument, doc,
55 'Custom element owner document should be the document, where custom element ' +
56 'type is registered');
59 var GeneratedConstructor2 = sharedRegistryDocument.registerElement(name2);
60 var customElement2 = new GeneratedConstructor2();
61 assert_equals(customElement2.ownerDocument, sharedRegistryDocument,
62 'Custom element owner document should be the document, where custom element ' +
63 'type is registered');
64 }, 'Custom element constructor sets owner document to the document, where custom element ' +
65 'type is registered. Test different documents with shared registry');
69 var doc = newHTMLDocument();
70 var sharedRegistryDocument = doc.implementation.createHTMLDocument('Document 2');
71 HTML5_ELEMENTS.forEach(function(tagName) {
72 var obj = doc.createElement(tagName);
73 var name = 'x-e-' + tagName;
74 var proto = Object.create(obj.constructor.prototype);
75 var GeneratedConstructor = doc.registerElement(name, {
79 var customElement = new GeneratedConstructor();
80 assert_equals(customElement.ownerDocument, doc,
81 'Custom element owner document should be the document, where custom element ' +
82 'type is registered');
84 var obj2 = sharedRegistryDocument.createElement(tagName);
85 var name2 = 'x-f-' + tagName;
86 var proto2 = Object.create(obj2.constructor.prototype);
87 var GeneratedConstructor2 = sharedRegistryDocument.registerElement(name2, {
91 var customElement2 = new GeneratedConstructor2();
92 assert_equals(customElement2.ownerDocument, sharedRegistryDocument,
93 'Custom element owner document should be the document, where custom element ' +
94 'type is registered');
96 }, 'Custom element constructor sets owner document to the document, where custom element ' +
97 'type is registered. Test constructor of extended HTML element for different documents ' +
98 'with shared registry');