Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Overflow: content inside -webkit-line-clamp keeps laying out after a nested scroller's scrollbar comes and goes</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<meta name="assert" content="Replacing the rows of a scroller whose scrollbar disappeared and then reappeared lays out the new rows.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.grid {
display: grid;
height: 300px;
width: 300px;
font: 20px/1 Ahem;
}
.outer {
overflow-y: auto;
}
.inner {
height: 100%;
overflow-y: auto;
}
.clamp {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}
.text {
display: block;
position: relative;
}
.overlay {
position: absolute;
inset: 0;
}
</style>
<div class="grid"><div class="outer"><div class="inner" id="inner"></div></div></div>
<script>
function render(count) {
inner.innerHTML = Array.from({ length: count }, (_, i) =>
`<div class="clamp"><span class="text">Row ${i}<span class="overlay"></span></span></div>`
).join('');
}
function nextRenderingUpdate() {
return new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
}
promise_test(async () => {
await document.fonts.ready;
render(30);
await nextRenderingUpdate();
render(5);
await nextRenderingUpdate();
render(30);
await nextRenderingUpdate();
const rows = inner.querySelectorAll(".clamp");
assert_equals(rows[rows.length - 1].getBoundingClientRect().height, 20, "last row height");
assert_equals(inner.scrollHeight, 600, "scroller scrollHeight");
}, "Rows added after the scrollbar disappeared and reappeared are laid out");
</script>