mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-26 18:59:35 +00:00
35 lines
845 B
HTML
35 lines
845 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 'baz'.
|
|
window.find('baz');
|
|
// Selection should be untouched, since 'baz' was not found
|
|
showSelection();
|
|
|
|
// Try to find 'bar'.
|
|
getSelection().empty();
|
|
window.find('bar');
|
|
|
|
// This should now fail.
|
|
try {
|
|
showSelection();
|
|
} catch (e) {
|
|
println(`Expected exception: ${e}`);
|
|
}
|
|
});
|
|
</script>
|