blob: 1c55a23f4bfba90f95197369e4edcdd331b26bc6 [file] [log] [blame]
<!DOCTYPE html><!-- webkit-test-runner [ ResizeObserverEnabled=true ] -->
<html>
<body>
<p>This tests that JS wrappers of targets removed from document to be delivered to an resize observer do not get collected.</p>
<pre id="log"></pre>
<script src="../resources/gc.js"></script>
<script>
if (window.testRunner)
testRunner.dumpAsText();
const targetCount = 5;
const iterationCount = 10;
var deadCount = 0;
async function runAll() {
if (window.testRunner)
testRunner.waitUntilDone();
for (let i = 0; i < iterationCount; ++i) {
runTest();
gc();
await new Promise((resolve) => requestAnimationFrame(resolve))
}
document.getElementById('log').textContent = (deadCount ? `FAIL - ${deadCount} targets lost JS wrappers` : 'PASS') + '\n';
if (window.testRunner)
testRunner.notifyDone();
}
function runTest() {
document.querySelectorAll('div').forEach(target => target.remove());
for (let i = 0; i < targetCount; ++i) {
let target = document.createElement('div');
target.myState = 'live';
document.body.appendChild(target);
}
document.querySelectorAll('div').forEach(target => observer.observe(target));
}
const observer = new ResizeObserver(entries => {
for (const entry of entries) {
if (entry.target.myState != 'live')
deadCount++;
}
});
runAll();
</script>
</body>
</html>