Add test for resizeTo(-1, -1) (#39211)

This test crashes in Servo, and passes on Gecko, Blink and Webkit.
The crash should be addressed by #39204.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-09-09 01:16:57 +02:00 committed by GitHub
parent fcf4beeac0
commit d469e5e564
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 43 additions and 0 deletions

View file

@ -630851,6 +630851,13 @@
{}
]
],
"resizeTo-negative.html": [
"d41d7bea8f980cb90565413cbb37122e1ea738c2",
[
null,
{}
]
],
"screen-detached-frame.html": [
"1d566d10f13e1055df6e6ef68017dbdd224ef422",
[

View file

@ -0,0 +1,2 @@
[resizeTo-negative.html]
expected: CRASH

View file

@ -0,0 +1,34 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-window-resizeto">
<link rel="help" href="https://github.com/servo/servo/pull/39204">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/rendering-utils.js"></script>
<script>
"use strict";
promise_test(async t => {
const w = window.open("/css/reference/blank.html", "", "width=600,height=450");
assert_not_equals(w, null, "Popup isn't null");
t.add_cleanup(() => w.close());
// Try as early as possible, when probably we only have about:blank.
w.resizeTo(-1, -1);
// Try again after load, some browser might ignore the former one.
if (w.location.href === "about:blank" || w.document.readyState !== "complete") {
await new Promise(resolve => w.addEventListener("load", resolve, {once: true}));
w.resizeTo(-1, -1);
}
// Wait a bit, so that the resize can finish. Note that listening for a "resize"
// event would result in a timeout if no resize occurred.
await waitForAtLeastOneFrame();
await waitForAtLeastOneFrame();
assert_greater_than(w.outerWidth, 0, "Popup width is positive");
assert_greater_than(w.outerHeight, 0, "Popup height is positive");
}, "resizeTo(-1, -1) might shrink window size, but it stays positive");
</script>