diff --git a/editor/libeditor/HTMLEditSubActionHandler.cpp b/editor/libeditor/HTMLEditSubActionHandler.cpp
index c537444a1a43..1a5c65f39ed6 100644
--- a/editor/libeditor/HTMLEditSubActionHandler.cpp
+++ b/editor/libeditor/HTMLEditSubActionHandler.cpp
@@ -561,11 +561,10 @@ nsresult HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal() {
case EditSubAction::eInsertTextComingFromIME:
case EditSubAction::eInsertLineBreak:
case EditSubAction::eInsertParagraphSeparator:
- return !StaticPrefs::
- editor_white_space_normalization_blink_compatible();
case EditSubAction::ePasteHTMLContent:
case EditSubAction::eInsertHTMLSource:
- return true;
+ return !StaticPrefs::
+ editor_white_space_normalization_blink_compatible();
default:
return false;
}
diff --git a/editor/libeditor/HTMLEditorDataTransfer.cpp b/editor/libeditor/HTMLEditorDataTransfer.cpp
index b19e06286111..dcab5762191d 100644
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -46,6 +46,7 @@
#include "mozilla/OwningNonNull.h"
#include "mozilla/Preferences.h"
#include "mozilla/Result.h"
+#include "mozilla/StaticPrefs_editor.h"
#include "mozilla/TextComposition.h"
#include "nsAString.h"
#include "nsCOMPtr.h"
@@ -847,6 +848,22 @@ Result HTMLEditor::HTMLWithContextInserter::Run(
NS_WARNING("HTMLEditor::GetBetterInsertionPointFor() failed");
return Err(NS_ERROR_FAILURE);
}
+ if (StaticPrefs::editor_white_space_normalization_blink_compatible()) {
+ Result pointToInsertOrError =
+ WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitAt(
+ mHTMLEditor, pointToInsert,
+ {WhiteSpaceVisibilityKeeper::NormalizeOption::
+ StopIfFollowingWhiteSpacesStartsWithNBSP});
+ if (MOZ_UNLIKELY(pointToInsertOrError.isErr())) {
+ NS_WARNING(
+ "WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitAt() failed");
+ return pointToInsertOrError.propagateErr();
+ }
+ pointToInsert = pointToInsertOrError.unwrap();
+ if (NS_WARN_IF(!pointToInsert.IsSetAndValidInComposedDoc())) {
+ return Err(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE);
+ }
+ }
const bool insertionPointWasInLink =
!!HTMLEditor::GetLinkElement(pointToInsert.GetContainer());
diff --git a/testing/web-platform/meta/editing/whitespaces/chrome-compat/insert-or-paste-image.tentative.html.ini b/testing/web-platform/meta/editing/whitespaces/chrome-compat/insert-or-paste-image.tentative.html.ini
index 4eade688c256..1b7bcc3a18c6 100644
--- a/testing/web-platform/meta/editing/whitespaces/chrome-compat/insert-or-paste-image.tentative.html.ini
+++ b/testing/web-platform/meta/editing/whitespaces/chrome-compat/insert-or-paste-image.tentative.html.ini
@@ -60,32 +60,3 @@
[insert-or-paste-image.tentative.html?execCommand-insertHTML]
- [document.execCommand("insertHTML") when "a[\] b"]
- expected: FAIL
-
- [document.execCommand("insertHTML") when "a [\] b"]
- expected: FAIL
-
- [document.execCommand("insertHTML") when "a [\] b"]
- expected: FAIL
-
- [document.execCommand("insertHTML") when "a [\] b"]
- expected: FAIL
-
- [document.execCommand("insertHTML") when "a [\] b"]
- expected: FAIL
-
- [document.execCommand("insertHTML") when "a [\] b"]
- expected: FAIL
-
- [document.execCommand("insertHTML") when "a [\] b"]
- expected: FAIL
-
- [document.execCommand("insertHTML") when "a [\] b"]
- expected: FAIL
-
- [document.execCommand("insertHTML") when "a [\] b"]
- expected: FAIL
-
- [document.execCommand("insertHTML") when "a [\]b"]
- expected: FAIL