4 <title>Invoke CALLBACK with ELEMENT as callback this value</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="Invoke CALLBACK with ELEMENT as callback this value">
8 <link rel="help" href="http://www.w3.org/TR/custom-elements/#enqueuing-and-invoking-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();
20 var GeneratedConstructor = doc.registerElement('x-a', {prototype: proto});
21 var customElement = new GeneratedConstructor();
23 doc.body.innerHTML = '<x-a id="x-a"></x-a>';
24 assert_equals(doc.querySelector('#x-a'), proto.createdCallbackThis,
25 '\'this\' value of the created callback should be the custom element');
26 }, 'Test \'this\' value inside created callback.');
29 testInIFrame('../../resources/x-element.html', function(doc) {
30 var proto = newHTMLElementPrototype();
31 doc.registerElement('x-element', {prototype: proto});
33 assert_equals(doc.querySelector('#x-element'), proto.attachedCallbackThis,
34 '\'this\' value of the attached callback should be the custom element');
35 }, 'Test \'this\' value inside attached callback.');
38 testInIFrame('../../resources/x-element.html', function(doc) {
39 var proto = newHTMLElementPrototype();
40 doc.registerElement('x-element', {prototype: proto});
42 var customElement = doc.querySelector('#x-element');
43 doc.body.removeChild(customElement);
44 assert_equals(customElement, proto.detachedCallbackThis,
45 '\'this\' value of the detached callback should be the custom element');
46 }, 'Test \'this\' value inside detached callback.');
50 var doc = newHTMLDocument();
51 var proto = newHTMLElementPrototype();
52 var GeneratedConstructor = doc.registerElement('x-b', {prototype: proto});
53 var customElement = new GeneratedConstructor();
55 customElement.setAttribute('class', 'someClass');
56 assert_equals(customElement, proto.attributeChangedCallbackThis,
57 '\'this\' value of the attributeChanged callback should be the custom element');
58 }, 'Test \'this\' value inside attributeChanged callback.');