diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp
index e663a90e4c..8e6c046518 100644
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -92,6 +92,9 @@ public:
return NS_OK;
}
+ AutoHideSelectionChanges hideSelectionChanges
+ (mFrame->GetConstFrameSelection());
+
if (mFrame) {
// SetSelectionRange leads to Selection::AddRange which flushes Layout -
// need to block script to avoid nested PrepareEditor calls (bug 642800).
@@ -1208,6 +1211,8 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
return NS_OK;
}
+ AutoHideSelectionChanges hideSelectionChanges(GetConstFrameSelection());
+
// Don't attempt to initialize recursively!
InitializationGuard guard(*this);
if (guard.IsInitializingRecursively()) {
diff --git a/dom/tests/mochitest/general/frameSelectEvents.html b/dom/tests/mochitest/general/frameSelectEvents.html
index e88c847c20..2931f5deb2 100644
--- a/dom/tests/mochitest/general/frameSelectEvents.html
+++ b/dom/tests/mochitest/general/frameSelectEvents.html
@@ -15,6 +15,10 @@
This is a random block of text
+
+
+
+