blob: 50fbfe05ddbbd693f275431ba1a766a7145200e9 [file] [log] [blame]
<!doctype html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<p>ResizeObserver garbage collection tests</p>
<div id="target1" style="width:100px;height:100px;">t1
</div>
<script>
'use strict';
let result;
let target = document.querySelector("#target1");
let test = async_test("ResizeObserver garbage collection");
function initResizeObserver() {
// The callback routine will be garbage collected unless it is kept alive
// in C++ code.
let ro = new ResizeObserver( entries => result = entries );
ro.observe(target);
}
function test1() {
initResizeObserver();
window.requestAnimationFrame( _ => {
test.step( _ => {
assert_not_equals(result, null, "initial notification");
assert_not_equals(window.gc, null, "window.gc required to run this test");
if (window.gc)
window.gc();
test1part2();
});
});
}
function test1part2() {
target.style.width = "200px";
result = null;
window.requestAnimationFrame( _ => {
test.step( _ => {
assert_not_equals(result, null, "resize notification did not happen because callback was garbage collected");
test.done();
});
});
}
test1();
</script>