Document-customElementRegistry.html (1470B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> 5 <link rel="help" href="https://github.com/whatwg/html/issues/10854"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 </head> 9 <body> 10 <script> 11 12 test(() => { 13 assert_equals(document.customElementRegistry, window.customElements); 14 }, 'customElementRegistry on a document should return window.customElements by default'); 15 16 test(() => { 17 const doc = document.implementation.createHTMLDocument('foo') 18 assert_equals(doc.customElementRegistry, null); 19 }, 'customElementRegistry on a document without a browsing context should return null'); 20 21 test((t) => { 22 const frame = document.createElement('iframe'); 23 t.add_cleanup(() => frame.remove()); 24 document.body.appendChild(frame); 25 assert_equals(frame.contentDocument.customElementRegistry, frame.contentWindow.customElements); 26 }, 'customElementRegistry on a document of a connected iframe should return contentWindow.customElements'); 27 28 test((t) => { 29 const frame = document.createElement('iframe'); 30 document.body.appendChild(frame); 31 const doc = frame.contentDocument; 32 const registry = frame.contentWindow.customElements; 33 frame.remove(); 34 assert_equals(doc.customElementRegistry, registry); 35 }, 'customElementRegistry on a document of a disconnected iframe should return contentWindow.customElements'); 36 37 </script> 38 </body> 39 </html>