diff --git a/Tests/LibWeb/Text/expected/Selection-setBaseAndExtent-without-common-root.txt b/Tests/LibWeb/Text/expected/Selection-setBaseAndExtent-without-common-root.txt new file mode 100644 index 00000000000..5db64a560d5 --- /dev/null +++ b/Tests/LibWeb/Text/expected/Selection-setBaseAndExtent-without-common-root.txt @@ -0,0 +1 @@ + PASS (Didn't crash) diff --git a/Tests/LibWeb/Text/input/Selection-setBaseAndExtent-without-common-root.html b/Tests/LibWeb/Text/input/Selection-setBaseAndExtent-without-common-root.html new file mode 100644 index 00000000000..2c47b0f7c99 --- /dev/null +++ b/Tests/LibWeb/Text/input/Selection-setBaseAndExtent-without-common-root.html @@ -0,0 +1,11 @@ + + + diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index 6ec1284454f..0fed976d158 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -307,7 +307,7 @@ WebIDL::ExceptionOr Selection::set_base_and_extent(JS::NonnullGCPtris_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).