diff --git a/LayoutTests/fast/dom/focus-dialog-blur-input-type-change-crash-expected.txt b/LayoutTests/fast/dom/focus-dialog-blur-input-type-change-crash-expected.txt new file mode 100644 index 000000000000..7ef22e9a431a --- /dev/null +++ b/LayoutTests/fast/dom/focus-dialog-blur-input-type-change-crash-expected.txt @@ -0,0 +1 @@ +PASS diff --git a/LayoutTests/fast/dom/focus-dialog-blur-input-type-change-crash.html b/LayoutTests/fast/dom/focus-dialog-blur-input-type-change-crash.html new file mode 100644 index 000000000000..252e939ebc92 --- /dev/null +++ b/LayoutTests/fast/dom/focus-dialog-blur-input-type-change-crash.html @@ -0,0 +1,21 @@ + + + + + diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp index d66a69bb8714..8c144a008390 100644 --- a/Source/WebCore/dom/Document.cpp +++ b/Source/WebCore/dom/Document.cpp @@ -4845,7 +4845,7 @@ bool Document::setFocusedElement(Element* element, const FocusOptions& options) } auto isNewElementFocusable = [&] { - if (!newFocusedElement) + if (!newFocusedElement || !newFocusedElement->isConnected()) return false; // Resolving isFocusable() may require matching :focus-within as if the focus was already on the new element. newFocusedElement->setHasTentativeFocus(true);