<script>
if (window.testRunner)
    testRunner.dumpAsText();

const doc = new Document();
const style = doc.createElementNS("http://www.w3.org/1999/xhtml", "style");
style.textContent = "div { color: blue }";
const div = doc.createElementNS("http://www.w3.org/1999/xhtml", "div");
const shadow = div.attachShadow({mode: 'open'});
shadow.appendChild(style);
doc.appendChild(div);
</script>
This test passes it doesn't crash.
