blob: 32b7847db8ac06e995a30e0a0e3227f16e550760 [file] [edit]
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script>
description('Tests that we do not hold on to any nodes');
function numberOfLiveNodes() {
return window.internals && window.internals.numberOfLiveNodes && window.internals.numberOfLiveNodes();
}
gc();
var beforeCount = numberOfLiveNodes();
const iterations = 100;
for (var j = 0; j < iterations; j++) {
var f = document.documentElement.appendChild(document.createElement('form'));
var i = f.appendChild(document.createElement('input'));
i.setAttribute('onclick', '');
i.remove();
f.remove();
}
// The conservative GC may not reclaim all unreachable nodes.
gc();
var delta = numberOfLiveNodes() - beforeCount;
if (delta < iterations / 2)
testPassed("did not leak");
else
testFailed(`leaked an unexpected number of nodes: ${delta} leaks in ${iterations} runs`);
</script>