<!DOCTYPE html>
<html>
<body>
<p>This tests allocating 1000 elements and triggering GC. GC should collect some elements.</p>
<script>

if (!window.internals)
    document.write('This test requires internals');
else {
    testRunner.dumpAsText();

    const initialNodeCount = internals.numberOfLiveNodes();

    const testCount = 1000;
    (() => {
        for (let i = 0; i < testCount; ++i)
            document.createElement('div').attributeStyleMap;
    })();

    if (window.GCController)
        GCController.collect();

    const nodeCountDiff = internals.numberOfLiveNodes() - initialNodeCount;
    document.write(nodeCountDiff < testCount / 1.5 ? 'PASS' : `FAIL - ${nodeCountDiff} nodes alive after triggering GC`);
}

</script>
</body>
</html>
