| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <p>Test having a <style scoped> element as a direct child of a ShadowRoot.</p> |
| <div id="host"> |
| </div> |
| <div id="ref"> |
| </div> |
| |
| <div id="console"></div> |
| |
| <script> |
| if (!window.internals) |
| debug("windows.internals not found!"); |
| else if (!window.internals.ensureShadowRoot) |
| debug("windows.internals.ensureShadowRoot not found!"); |
| else if (!window.internals.numberOfScopedHTMLStyleChildren) |
| debug("windows.internals.numberOfScopedHTMLStyleChildren not found!"); |
| else { |
| var ref = document.getElementById('ref'); |
| var host = document.getElementById('host'); |
| var sr = internals.ensureShadowRoot(host); |
| var style = document.createElement('style'); |
| style.setAttribute('scoped', 'scoped'); |
| |
| debug("--- Initial ---"); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0"); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> out of document, scoped */ |
| |
| debug("--- Attaching <style scoped> ---"); |
| sr.appendChild(style); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0"); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, scoped */ |
| |
| debug("--- Removing host ---"); |
| host.parentNode.removeChild(host); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0"); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> out of document, scoped */ |
| |
| debug("--- Inserting host ---"); |
| ref.parentNode.insertBefore(host, ref); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0"); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, scoped */ |
| |
| debug("--- Unsetting @scoped ---"); |
| style.scoped = false; |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0"); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, not scoped */ |
| |
| debug("--- Setting @scoped ---"); |
| style.scoped = true; |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0"); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "1"); /* <style> in shadow, scoped */ |
| |
| debug("--- Detaching <style scoped> ---"); |
| sr.removeChild(style); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "0"); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> out of document, scoped */ |
| |
| debug("--- Attaching <style scoped> under host ---"); |
| host.appendChild(style); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(host)", "1"); |
| shouldBe("internals.numberOfScopedHTMLStyleChildren(sr)", "0"); /* <style> in tree, scoped */ |
| |
| debug("--- DONE ---"); |
| } |
| var successfullyParsed = true; |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |