Skip to content

Truly independent web browser

Tests/LibWeb: Hold the box in the ResizeObserver removal tests

sideshowbarker345f8ef277d7
diff --git a/Tests/LibWeb/Text/input/ResizeObserver/notify-if-node-is-removed.html b/Tests/LibWeb/Text/input/ResizeObserver/notify-if-node-is-removed.html
index 9e44e56e6fb..5e2c4a471a8 100644
--- a/Tests/LibWeb/Text/input/ResizeObserver/notify-if-node-is-removed.html
+++ b/Tests/LibWeb/Text/input/ResizeObserver/notify-if-node-is-removed.html
@@ -13,8 +13,13 @@
</body>
<script src="../include.js"></script>
<script>
+ // Reachable for the whole test: A ResizeObserver holds its targets weakly, so a collection could otherwise take the
+ // removed box, and the observer with it, before the callback that reports the removal.
+ let box = null;
+ let resizeObserver = null;
+
promiseTest(async () => {
- const box = document.getElementById("box");
+ box = document.getElementById("box");
let resolve = null;
function createResizeObserverPromise() {
@@ -23,7 +28,7 @@
});
}
- const resizeObserver = new ResizeObserver(entries => {
+ resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) {
const { width, height } = entry.contentRect;
println(`Size changed: ${width}px x ${height}px`);
diff --git a/Tests/LibWeb/Text/input/ResizeObserver/notify-if-parent-is-removed.html b/Tests/LibWeb/Text/input/ResizeObserver/notify-if-parent-is-removed.html
index 61b2799dc44..b41d6ecbea0 100644
--- a/Tests/LibWeb/Text/input/ResizeObserver/notify-if-parent-is-removed.html
+++ b/Tests/LibWeb/Text/input/ResizeObserver/notify-if-parent-is-removed.html
@@ -13,8 +13,13 @@
</body>
<script src="../include.js"></script>
<script>
+ // Reachable for the whole test: A ResizeObserver holds its targets weakly, so a collection could otherwise take the
+ // removed box, and the observer with it, before the callback that reports the removal.
+ let box = null;
+ let resizeObserver = null;
+
promiseTest(async () => {
- const box = document.getElementById("box");
+ box = document.getElementById("box");
let resolve = null;
function createResizeObserverPromise() {
@@ -23,7 +28,7 @@
});
}
- const resizeObserver = new ResizeObserver(entries => {
+ resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) {
const { width, height } = entry.contentRect;
println(`Size changed: ${width}px x ${height}px`);