LibWeb: Don't try to set selection with anchor/focus in different roots

If the anchor and focus nodes are not within the same document, we can't
use them for a selection range.

Found by Domato.
This commit is contained in:
Andreas Kling 2024-07-19 16:39:34 +02:00 committed by Andreas Kling
commit 416c478876
Notes: github-actions[bot] 2024-07-20 07:31:52 +00:00
3 changed files with 13 additions and 1 deletions

View file

@ -0,0 +1,11 @@
<body>
<script src="include.js"></script>
<script>
test(() => {
let newDoc = document.implementation.createHTMLDocument("foo");
let newDocP = newDoc.createElement("p");
let selection = window.getSelection();
selection.setBaseAndExtent(document.body, 0, newDocP, 0);
println("PASS (Didn't crash)");
});
</script>