Bug 612565 - Don't recurse into document modification listeners for editable documents if the modification to the document is made on the bogus BR node; r=roc a=blocking-beta8+
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 16 Nov 2010 15:43:46 -0500
changeset 57597 a80edd37a40a0029896fcc9bb1b30f365c537050
parent 57596 1b815a3b4250c99f643befc06d74a83b1a9f8a36
child 57598 ef83567ee8d8ce284a513c640dab55e0c366c27e
push id17000
push usereakhgari@mozilla.com
push dateTue, 16 Nov 2010 20:45:27 +0000
treeherdermozilla-central@ef83567ee8d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blocking-beta8
bugs612565
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 612565 - Don't recurse into document modification listeners for editable documents if the modification to the document is made on the bogus BR node; r=roc a=blocking-beta8+ This fixes an unresponsive script dialog error for Etherpad pages (possibly among other websites).
editor/libeditor/html/crashtests/612565-1.html
editor/libeditor/html/crashtests/crashtests.list
editor/libeditor/html/nsHTMLEditor.cpp
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/html/crashtests/612565-1.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <iframe></iframe>
+  </body>
+  <script>
+    onload = function() {
+      var i = document.querySelector("iframe");
+      var doc = i.contentDocument;
+      doc.body.appendChild(doc.createTextNode("foo"));
+      doc.designMode = "on";
+      while (doc.body.firstChild) {
+        doc.body.removeChild(doc.body.firstChild);
+      }
+    };
+  </script>
+</html>
--- a/editor/libeditor/html/crashtests/crashtests.list
+++ b/editor/libeditor/html/crashtests/crashtests.list
@@ -13,8 +13,9 @@ load 456727-1.html
 load 456727-2.html
 asserts(1) load 467647-1.html # bug 382210
 load 499844-1.html
 load 503709-1.xhtml
 load 513375-1.xhtml
 load 535632-1.xhtml
 load 574558-1.xhtml
 load 582138-1.xhtml
+load 612565-1.html
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -3860,30 +3860,40 @@ nsHTMLEditor::ContentInserted(nsIDocumen
     return;
   }
 
   if (ShouldReplaceRootElement()) {
     ResetRootElementAndEventTarget();
   }
   // We don't need to handle our own modifications
   else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) {
+    nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aChild);
+    if (node && IsMozEditorBogusNode(node)) {
+      // Ignore insertion of the bogus node
+      return;
+    }
     mRules->DocumentModified();
   }
 }
 
 void
 nsHTMLEditor::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
                              nsIContent* aChild, PRInt32 aIndexInContainer,
                              nsIContent* aPreviousSibling)
 {
   if (SameCOMIdentity(aChild, mRootElement)) {
     ResetRootElementAndEventTarget();
   }
   // We don't need to handle our own modifications
   else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) {
+    nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aChild);
+    if (node && IsMozEditorBogusNode(node)) {
+      // Ignore removal of the bogus node
+      return;
+    }
     mRules->DocumentModified();
   }
 }
 
 #ifdef XP_MAC
 #pragma mark -
 #pragma mark  support utils
 #pragma mark -