chromium/third_party/blink/web_tests/fast/dom/dom-method-document-change.html

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

handler = function()
{
    this.removeEventListener("DOMNodeRemoved", handler, false);
    doc.adoptNode(this.parentElement);
}

showFailure = function(s)
{
    document.body.innerHTML = "FAILURE: " + s;
}

window.onload = function()
{
    element1 = document.createElement("x");
    element2 = document.createElement("x");
    element3 = document.createElement("x");
    parent   = document.createElement("x");
    dummy    = document.createElement("x");
    
    doc = document.implementation.createHTMLDocument();
    
    parent.appendChild(element1);
    element1.addEventListener("DOMNodeRemoved", handler, false);
    try {
        document.body.appendChild(element1);
    } catch (e) { }
    if (element1.ownerDocument != element1.parentElement.ownerDocument)
        return showFailure("appendChild");
    
    document.adoptNode(parent);
    parent.appendChild(element2);
    try {
        doc.body.insertBefore(element2, dummy);
    } catch (e) { }
    if (element2.ownerDocument != element2.parentElement.ownerDocument)
        return showFailure("insertBefore");
    
    parent.appendChild(element3);
    try {
        doc.body.replaceChild(element3, dummy);
    } catch (e) { }
    if (element3.ownerDocument != element3.parentElement.ownerDocument)
        return showFailure("replaceChild");
}
</script>
</head>
<body>SUCCESS</body>
</html>