OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 <script> | 5 <script> |
6 description("This test ensures that the lifecycle callback of a parser-made elem
ent is visible in following script block.") | 6 description("This test ensures that the lifecycle callback of a parser-made elem
ent is visible in following script block.") |
7 | 7 |
8 window.callbacksCalled = []; | 8 window.callbacksCalled = []; |
9 | 9 |
10 function trackingReadyCallback() | 10 function trackingReadyCallback() |
11 { | 11 { |
12 window.callbacksCalled.push(this.id); | 12 window.callbacksCalled.push(this.id); |
13 } | 13 } |
14 | 14 |
15 document.register("x-foo", { prototype: Object.create(HTMLElement.prototype, { c
reatedCallback: { value: trackingReadyCallback } }) }); | 15 document.registerElement("x-foo", { prototype: Object.create(HTMLElement.prototy
pe, { createdCallback: { value: trackingReadyCallback } }) }); |
16 document.register("x-bar", { extends: "div", prototype: Object.create(HTMLDivEle
ment.prototype, { createdCallback: { value: trackingReadyCallback } }) }); | 16 document.registerElement("x-bar", { extends: "div", prototype: Object.create(HTM
LDivElement.prototype, { createdCallback: { value: trackingReadyCallback } }) })
; |
17 document.register("x-baz", { prototype: Object.create(HTMLElement.prototype, { c
reatedCallback: { value: trackingReadyCallback } }) }); | 17 document.registerElement("x-baz", { prototype: Object.create(HTMLElement.prototy
pe, { createdCallback: { value: trackingReadyCallback } }) }); |
18 </script> | 18 </script> |
19 </head> | 19 </head> |
20 <body> | 20 <body> |
21 <div id="container"> | 21 <div id="container"> |
22 <script> | 22 <script> |
23 // Testing element siblings | 23 // Testing element siblings |
24 window.callbacksCalled = []; | 24 window.callbacksCalled = []; |
25 container.innerHTML = "<x-foo id='a'></x-foo><div id='b' is='x-bar'></div><x-baz
id='c'></x-baz>"; | 25 container.innerHTML = "<x-foo id='a'></x-foo><div id='b' is='x-bar'></div><x-baz
id='c'></x-baz>"; |
26 shouldBe("window.callbacksCalled", "['a', 'b', 'c']"); | 26 shouldBe("window.callbacksCalled", "['a', 'b', 'c']"); |
27 | 27 |
28 // Testing nested elements | 28 // Testing nested elements |
29 window.callbacksCalled = []; | 29 window.callbacksCalled = []; |
30 container.innerHTML = "<x-foo id='a'><div id='b' is='x-bar'><x-baz id='c'></x-ba
z></div></x-foo>"; | 30 container.innerHTML = "<x-foo id='a'><div id='b' is='x-bar'><x-baz id='c'></x-ba
z></div></x-foo>"; |
31 shouldBe("window.callbacksCalled", "['a', 'b', 'c']"); | 31 shouldBe("window.callbacksCalled", "['a', 'b', 'c']"); |
32 </script> | 32 </script> |
33 </body> | 33 </body> |
34 </html> | 34 </html> |
OLD | NEW |