<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description('Test DOMJIT documentElement accessor works after the documentElement is changed.');

var target = null;
var result = null;

function testNull(element, result)
{
    return element.documentElement === result;
}

function runTest()
{
    target = document.implementation.createDocument('', null, null);
    var element = target.createElement('html');
    result = null;
    for (var i = 0; i < 1e4; ++i)
        shouldBeTrueQuiet(`testNull(target, result)`);

    target.appendChild(element);
    shouldBeFalse(`testNull(target, result)`);
    result = element;
    shouldBeTrue(`testNull(target, result)`);

}
runTest();
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
