Assertion failure at TreeScopeAdopter::moveNodeToNewDocument()
authormorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Oct 2012 07:08:58 +0000 (07:08 +0000)
committermorrita@google.com <morrita@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Oct 2012 07:08:58 +0000 (07:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99510

Reviewed by Kent Tamura.

Source/WebCore:

Shadow DOM notification call didn't have checks for mutation detection.
This change adds such checks.

Test: fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html

* dom/ContainerNodeAlgorithms.cpp:
(WebCore::ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument):
(WebCore::ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument):

LayoutTests:

* fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style-expected.txt: Added.
* fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@131709 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/ContainerNodeAlgorithms.cpp

index 3b76a75..260256f 100644 (file)
@@ -1,3 +1,13 @@
+2012-10-18  MORITA Hajime  <morrita@google.com>
+
+        Assertion failure at TreeScopeAdopter::moveNodeToNewDocument()
+        https://bugs.webkit.org/show_bug.cgi?id=99510
+
+        Reviewed by Kent Tamura.
+
+        * fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style-expected.txt: Added.
+        * fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html: Added.
+
 2012-10-18  Zan Dobersek  <zandobersek@gmail.com>
 
         Unreviewed GTK gardening.
diff --git a/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style-expected.txt b/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style-expected.txt
new file mode 100644 (file)
index 0000000..46cc850
--- /dev/null
@@ -0,0 +1 @@
+PASS unless crash.
diff --git a/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html b/LayoutTests/fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html
new file mode 100644 (file)
index 0000000..8db91fa
--- /dev/null
@@ -0,0 +1,20 @@
+<head>
+<style> </style>
+</head>
+<body>
+<script>
+testRunner.dumpAsText();
+testRunner.waitUntilDone();
+var docElement = document.documentElement;
+textArea = document.createElement("textarea");
+textArea.setAttribute("autofocus", "");
+textArea.appendChild(document.head);
+textArea.addEventListener("DOMFocusIn", function () { docElement.innerHTML = ""; }, false);
+docElement.appendChild(textArea);
+document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null).adoptNode(textArea);
+window.setTimeout(function() {
+    document.body.innerHTML = "PASS unless crash.";
+    testRunner.notifyDone();
+}, 0);
+</script>
+</body>
index 2a239dc..a1fca11 100644 (file)
@@ -1,3 +1,19 @@
+2012-10-18  MORITA Hajime  <morrita@google.com>
+
+        Assertion failure at TreeScopeAdopter::moveNodeToNewDocument()
+        https://bugs.webkit.org/show_bug.cgi?id=99510
+
+        Reviewed by Kent Tamura.
+
+        Shadow DOM notification call didn't have checks for mutation detection.
+        This change adds such checks.
+
+        Test: fast/forms/textarea/textarea-autofocus-removal-while-focusing-with-style.html
+
+        * dom/ContainerNodeAlgorithms.cpp:
+        (WebCore::ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument):
+        (WebCore::ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument):
+
 2012-10-17  Kentaro Hara  <haraken@chromium.org>
 
         Unreviewed. Rebaselined run-bindings-tests.
index f565adb..59dac74 100644 (file)
@@ -48,8 +48,10 @@ void ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument(ContainerN
 
     if (ElementShadow* shadow = toElement(node)->shadow()) {
         ShadowRootVector roots(shadow);
-        for (size_t i = 0; i < roots.size(); ++i)
-            notifyNodeInsertedIntoDocument(roots[i].get());
+        for (size_t i = 0; i < roots.size(); ++i) {
+            if (node->inDocument() && roots[i]->host() == node)
+                notifyNodeInsertedIntoDocument(roots[i].get());
+        }
     }
 }
 
@@ -83,8 +85,10 @@ void ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument(ContainerNode
 
     if (ElementShadow* shadow = toElement(node)->shadow()) {
         ShadowRootVector roots(shadow);
-        for (size_t i = 0; i < roots.size(); ++i)
-            notifyNodeRemovedFromDocument(roots[i].get());
+        for (size_t i = 0; i < roots.size(); ++i) {
+            if (!node->inDocument() && roots[i]->host() == node)
+                notifyNodeRemovedFromDocument(roots[i].get());
+        }
     }
 }