ladybird/Tests/LibWeb/Text/input/HTML/Window-find-mutations.html
Jelle Raaijmakers c3a5e8e266 LibWeb: Invalidate viewport's text blocks cache on layout update
156c1083e9 introduced a text blocks cache
for better performance when searching through text on a page, but when
we partially recreate the layout tree, this cache does not get
invalidated. We now rebuild the entire text blocks cache after a layout
update.
2025-05-15 11:44:32 +01:00

30 lines
709 B
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<div>foobar</div>
<script>
test(() => {
function showSelection() {
let range = getSelection().getRangeAt(0);
println(`Selection: ${range.startContainer} ${range.startOffset} - ${range.endContainer} ${range.endOffset}`);
}
// Select 'foobar'.
window.find('foobar');
showSelection();
// Remove 'bar'.
document.querySelector('div').childNodes[0].deleteData(3, 3);
showSelection();
// Try to find 'bar'.
getSelection().empty();
window.find('bar');
// This should now fail.
try {
showSelection();
} catch (e) {
println(`Expected exception: ${e}`);
}
});
</script>