blob: 018921aa04ad57518b585a99c5897da1cd183475 [file] [log] [blame]
<!DOCTYPE html><!-- webkit-test-runner [ IntersectionObserverEnabled=true ] -->
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/gc.js"></script>
<body>
<div id="target" style="width: 100px; height: 100px; background-color: green"></div>
<script>
function observerShouldBeRemoved()
{
return new Promise(function(resolve) {
function testIfRemoved() {
gc();
if (internals && internals.numberOfIntersectionObservers(document) == 0)
resolve();
else
requestAnimationFrame(testIfRemoved);
}
testIfRemoved();
});
}
async_test(function(t) {
let observer = new IntersectionObserver(function(entries) {
if (entries[0].isIntersecting) {
entries[0].target.remove();
observerShouldBeRemoved().then(function() {
t.done();
});
}
});
observer.observe(document.getElementById("target"));
assert_equals(internals.numberOfIntersectionObservers(document), 1);
}, "IntersectionObserver doesn't keep unreachable target alive");
</script>
</body>
</html>