mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
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:
parent
4e0edd42b9
commit
416c478876
Notes:
github-actions[bot]
2024-07-20 07:31:52 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/416c4788763 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/721
|
@ -0,0 +1 @@
|
|||
PASS (Didn't crash)
|
|
@ -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>
|
|
@ -307,7 +307,7 @@ WebIDL::ExceptionOr<void> Selection::set_base_and_extent(JS::NonnullGCPtr<DOM::N
|
|||
return WebIDL::IndexSizeError::create(realm(), "Focus offset points outside of the focus node"_fly_string);
|
||||
|
||||
// 2. If document associated with this is not a shadow-including inclusive ancestor of anchorNode or focusNode, abort these steps.
|
||||
if (!(m_document->is_shadow_including_inclusive_ancestor_of(anchor_node) || m_document->is_shadow_including_inclusive_ancestor_of(focus_node)))
|
||||
if (!m_document->is_shadow_including_inclusive_ancestor_of(anchor_node) || !m_document->is_shadow_including_inclusive_ancestor_of(focus_node))
|
||||
return {};
|
||||
|
||||
// 3. Let anchor be the boundary point (anchorNode, anchorOffset) and let focus be the boundary point (focusNode, focusOffset).
|
||||
|
|
Loading…
Reference in a new issue