4 <title>The custom element prototype must be set just prior to invoking created callback</title>
5 <meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
6 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
7 <meta name="assert" content="The custom element prototype must be set just prior to invoking callback.">
8 <link rel="help" href="http://www.w3.org/TR/custom-elements/#types-of-callbacks">
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 var proto = newHTMLElementPrototype();
21 doc.body.innerHTML = '<x-a></x-a>';
22 doc.registerElement('x-a', {prototype: proto});
23 assert_equals(proto.createdCallbackThis.constructor.prototype, proto,
24 'The custom element prototype is incorrect inside created callback');
25 }, 'Test custom element prototype inside created callback when custom element is created ' +
26 'in HTML before registration of a custom element');
30 var doc = newHTMLDocument();
31 var proto = newHTMLElementPrototype();
33 doc.registerElement('x-b', {prototype: proto});
34 doc.body.innerHTML = '<x-b></x-b>';
35 assert_equals(proto.createdCallbackThis.constructor.prototype, proto,
36 'The custom element prototype is incorrect inside created callback');
37 }, 'Test custom element prototype inside created callback when custom element is created ' +
38 'in HTML after registration of a custom element');
42 var doc = newHTMLDocument();
43 var proto = newHTMLElementPrototype();
44 var customElement = doc.createElement('x-c');
46 doc.body.appendChild(customElement);
47 doc.registerElement('x-c', {prototype: proto});
48 assert_equals(proto.createdCallbackThis.constructor.prototype, proto,
49 'The custom element prototype is incorrect inside created callback');
50 }, 'Test custom element prototype inside created callback when custom element is created ' +
51 'via document.createElement() before registration of a custom element');
55 var doc = newHTMLDocument();
56 var proto = newHTMLElementPrototype();
57 doc.registerElement('x-d', {prototype: proto});
59 var customElement = doc.createElement('x-d');
60 doc.body.appendChild(customElement);
61 assert_equals(proto.createdCallbackThis.constructor.prototype, proto,
62 'The custom element prototype is incorrect inside created callback');
63 }, 'Test custom element prototype inside created callback when custom element is created ' +
64 'via document.createElement() after registration of a custom element');
68 var doc = newHTMLDocument();
69 var proto = newHTMLElementPrototype();
70 var GeneratedConstructor = doc.registerElement('x-e', {prototype: proto});
71 var customElement = new GeneratedConstructor();
73 assert_equals(proto.createdCallbackThis.constructor.prototype, proto,
74 'The custom element prototype is incorrect inside created callback');
75 }, 'Test custom element prototype inside created callback when custom element is created ' +
76 'via constructor returned by method registerElement');
79 testInIFrame('../../resources/x-element.html', function(doc) {
80 var proto = newHTMLElementPrototype();
81 doc.registerElement('x-element', {prototype: proto});
82 assert_equals(proto.createdCallbackThis.constructor.prototype, proto,
83 'The custom element prototype is incorrect inside created callback');
84 }, 'Test custom element prototype inside created callback when custom element is created ' +
85 'by UA parser before registration of a custom element');