test_custom_element_callback_innerhtml.html (1139B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1102502 5 --> 6 <head> 7 <title>Test for connected callback for element created in the document by the parser</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1102502">Bug 1102502</a> 13 <div id="container"></div> 14 15 <script> 16 17 SimpleTest.waitForExplicitFinish(); 18 19 var connectedCallbackCount = 0; 20 21 class Foo extends HTMLElement { 22 connectedCallback() { 23 ok(true, "connectedCallback should be called when the parser creates an element in the document."); 24 connectedCallbackCount++; 25 // connectedCallback should be called twice, once for the element created for innerHTML and 26 // once for the element created in this document. 27 if (connectedCallbackCount == 2) { 28 SimpleTest.finish(); 29 } 30 } 31 }; 32 33 customElements.define("x-foo", Foo); 34 35 var container = document.getElementById("container"); 36 container.innerHTML = '<x-foo></x-foo>'; 37 38 </script> 39 40 <x-foo></x-foo> 41 42 </body> 43 </html>