LibWeb: Add test for document.execCommand("delete")

Anchor the minimum functionality for this. WPT has an extensive suite
to test editing functionalities, but they all take a long time to
execute - so let's have a simple regression test in-tree for now.
This commit is contained in:
Jelle Raaijmakers 2024-11-30 12:20:44 +01:00 committed by Andreas Kling
parent 4b0d8cbfad
commit 033cd9cab3
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,2 @@
Before: foobar
After: fobar

View File

@ -0,0 +1,18 @@
<script src="../include.js"></script>
<div contenteditable="true">foobar</div>
<script>
test(() => {
var divElm = document.querySelector('div');
println(`Before: ${divElm.textContent}`);
// Put cursor after 'foo'
var range = document.createRange();
range.setStart(divElm.childNodes[0], 3);
getSelection().addRange(range);
// Press backspace
document.execCommand('delete');
println(`After: ${divElm.textContent}`);
});
</script>