chromium/third_party/blink/web_tests/fast/dom/shadow/shadow-root-append.html

<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<p>This test checks that appending shadow root as a child does not crash.</p>
<pre id="console"></pre>
<div id="container"></div>

<script>
function doTest() {
    if (!window.internals) {
        debug('This test runs on DRT only');
        return;
    }

    var div = document.createElement('div');
    root = div.attachShadow({mode: 'open'});
    root.appendChild(document.createTextNode('SS'));

    container = document.getElementById('container');
    container.appendChild(root);

    shouldBeNull('root.firstChild');
    shouldBe('container.firstChild.textContent', '"SS"');

    var div = document.createElement('div');
    root = div.attachShadow({mode: 'open'});
    root.appendChild(document.createTextNode('PA'));

    container.insertBefore(root, container.firstChild);

    shouldBeNull('root.firstChild');
    shouldBe('container.firstChild.textContent', '"PA"');
    shouldNotBe('container.firstChild', 'container.lastChild');
}

doTest();
var successfullyParsed = true;
</script>
</body>
</html>