diff --git a/editor/libeditor/HTMLStyleEditor.cpp b/editor/libeditor/HTMLStyleEditor.cpp index baa1d0e40630..759c11987654 100644 --- a/editor/libeditor/HTMLStyleEditor.cpp +++ b/editor/libeditor/HTMLStyleEditor.cpp @@ -2043,6 +2043,11 @@ HTMLEditor::SplitAncestorStyledInlineElementsAtRangeEdges( return Err(NS_ERROR_FAILURE); } range.SetStart(std::move(startOfRange)); + } else if (MOZ_UNLIKELY(!range.IsPositioned())) { + NS_WARNING( + "HTMLEditor::SplitAncestorStyledInlineElementsAt() caused unexpected " + "DOM tree"); + return Err(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE); } return result; }(); @@ -2063,7 +2068,7 @@ HTMLEditor::SplitAncestorStyledInlineElementsAtRangeEdges( return result; } tracker.FlushAndStopTracking(); - if (result.inspect().Handled()) { + if (NS_WARN_IF(result.inspect().Handled())) { auto endOfRange = result.inspect().AtSplitPoint(); if (!endOfRange.IsSet()) { result.inspect().IgnoreCaretPointSuggestion(); @@ -2073,6 +2078,11 @@ HTMLEditor::SplitAncestorStyledInlineElementsAtRangeEdges( return Err(NS_ERROR_FAILURE); } range.SetEnd(std::move(endOfRange)); + } else if (MOZ_UNLIKELY(!range.IsPositioned())) { + NS_WARNING( + "HTMLEditor::SplitAncestorStyledInlineElementsAt() caused unexpected " + "DOM tree"); + return Err(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE); } return result; }(); diff --git a/testing/web-platform/tests/editing/crashtests/removeformat-from-DOMNodeRemoved.html b/testing/web-platform/tests/editing/crashtests/removeformat-from-DOMNodeRemoved.html new file mode 100644 index 000000000000..3f78f9943621 --- /dev/null +++ b/testing/web-platform/tests/editing/crashtests/removeformat-from-DOMNodeRemoved.html @@ -0,0 +1,29 @@ + + + + + + + + + + +
+ +a + +
+ +