diff --git a/Tests/LibWeb/Text/expected/HTML/HTMLInputElement-select-crash.txt b/Tests/LibWeb/Text/expected/HTML/HTMLInputElement-select-crash.txt new file mode 100644 index 00000000000..aaecaf93c4a --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/HTMLInputElement-select-crash.txt @@ -0,0 +1 @@ +PASS (didn't crash) diff --git a/Tests/LibWeb/Text/input/HTML/HTMLInputElement-select-crash.html b/Tests/LibWeb/Text/input/HTML/HTMLInputElement-select-crash.html new file mode 100644 index 00000000000..81fc5123be0 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/HTMLInputElement-select-crash.html @@ -0,0 +1,11 @@ + + + diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 2a573ce11af..158cfe9d526 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -2365,6 +2365,9 @@ HTMLInputElement::ValueAttributeMode HTMLInputElement::value_attribute_mode() co void HTMLInputElement::selection_was_changed(size_t selection_start, size_t selection_end) { + if (!m_text_node) + return; + document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end)); if (auto selection = document().get_selection()) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index 4d0b5dcd304..4c0cdb6a818 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -463,6 +463,9 @@ void HTMLTextAreaElement::queue_firing_input_event() void HTMLTextAreaElement::selection_was_changed(size_t selection_start, size_t selection_end) { + if (!m_text_node) + return; + document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end)); if (auto selection = document().get_selection())