Files
ladybird/Tests/LibWeb/Crash/HTML/iframe-document-open-during-rendering.html
Jelle Raaijmakers dd6d17d60d LibWeb: Don't crash accessing stale nested navigable paintable
The scroll state collection loop in
record_display_list_and_scroll_state() called paintable() on hosted
documents, which asserts layout is up to date. This crashes when a
nested document has stale layout but a cached display list, e.g. a
render-blocked iframe whose DOM was modified by document.open().
Since scroll offsets are independent of layout freshness, use
unsafe_paintable() to skip the assertion.
2026-03-24 12:47:02 +01:00

36 lines
990 B
HTML

<!DOCTYPE html>
<html class="test-wait">
<body style="height: 2000px">
<iframe id="frame"></iframe>
<script>
function afterPaintAndTask(callback) {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
setTimeout(callback, 0);
});
});
}
const frame = document.getElementById("frame");
frame.srcdoc = "<body><p>Content</p></body>";
frame.onload = () => {
frame.contentDocument.body.offsetHeight;
afterPaintAndTask(() => {
frame.contentDocument.open();
// Scroll the viewport so the parent needs repaint without invalidating its cached display list.
window.scrollTo(0, 1);
afterPaintAndTask(() => {
frame.contentDocument.write("<body></body>");
frame.contentDocument.close();
document.documentElement.classList.remove("test-wait");
});
});
};
</script>
</body>
</html>