Diff
Modified: trunk/LayoutTests/ChangeLog (169006 => 169007)
--- trunk/LayoutTests/ChangeLog 2014-05-18 05:29:36 UTC (rev 169006)
+++ trunk/LayoutTests/ChangeLog 2014-05-18 06:11:24 UTC (rev 169007)
@@ -1,3 +1,17 @@
+2014-05-17 Maciej Stachowiak <[email protected]>
+
+ Don't attempt to update id or name for nodes that are already removed
+ https://bugs.webkit.org/show_bug.cgi?id=133041
+
+ Reviewed by Sam Weinig.
+
+ Test originally by Dan Bates.
+
+ * fast/dom/remove-element-with-id-that-was-inserted-on-DOMNodeRemoved-expected.txt: Added.
+ * fast/dom/remove-element-with-id-that-was-inserted-on-DOMNodeRemoved.html: Added.
+ * fast/dom/remove-element-with-name-that-was-inserted-on-DOMNodeRemoved-expected.txt: Added.
+ * fast/dom/remove-element-with-name-that-was-inserted-on-DOMNodeRemoved.html: Added.
+
2014-05-17 Alexey Proskuryakov <[email protected]>
REGRESSION (NetworkProcess): Trying to use appcache fallback crashes in ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache
Added: trunk/LayoutTests/fast/dom/remove-element-with-id-that-was-inserted-on-DOMNodeRemoved-expected.txt (0 => 169007)
--- trunk/LayoutTests/fast/dom/remove-element-with-id-that-was-inserted-on-DOMNodeRemoved-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/remove-element-with-id-that-was-inserted-on-DOMNodeRemoved-expected.txt 2014-05-18 06:11:24 UTC (rev 169007)
@@ -0,0 +1 @@
+PASS, removed element, with HTML attribute id, which was inserted on event DOMNodeRemoved.
Added: trunk/LayoutTests/fast/dom/remove-element-with-id-that-was-inserted-on-DOMNodeRemoved.html (0 => 169007)
--- trunk/LayoutTests/fast/dom/remove-element-with-id-that-was-inserted-on-DOMNodeRemoved.html (rev 0)
+++ trunk/LayoutTests/fast/dom/remove-element-with-id-that-was-inserted-on-DOMNodeRemoved.html 2014-05-18 06:11:24 UTC (rev 169007)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head></head> <!-- This element isn't necessary, but makes it straightforward to reason about the test when debugging it. -->
+<body id="declarativeBody"></body>
+<!-- Notice a <script> is only executed once. -->
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+var savedDocumentElement;
+function appendBodyElementToSavedDocument()
+{
+ document.removeEventListener("DOMNodeRemoved", appendBodyElementToSavedDocument, false);
+ savedDocumentElement.appendChild(document.createElement("body")).id = "programmaticBody";
+}
+
+function insertSavedDocument()
+{
+ document.appendChild(savedDocumentElement); // Will execute <script id="script2">.
+}
+
+savedDocumentElement = document.documentElement;
+document.addEventListener("DOMNodeRemoved", appendBodyElementToSavedDocument, false);
+document.removeChild(savedDocumentElement); // Prevents <script id="script2"> from running since it won't be in the document when we fall off the end of this <script>.
+window.setTimeout(insertSavedDocument, 0);
+</script>
+<!-- This must be in its own <script> so that we execute it (for the first time) when we re-insert it into the document in insertSavedDocument(). -->
+<script id="script2">
+document.write("PASS, removed element, with HTML attribute id, which was inserted on event DOMNodeRemoved."); // Destroys the entire document, including <body id="declarativeBody"> and <body id="programmaticBody">.
+</script>
+</html>
Added: trunk/LayoutTests/fast/dom/remove-element-with-name-that-was-inserted-on-DOMNodeRemoved-expected.txt (0 => 169007)
--- trunk/LayoutTests/fast/dom/remove-element-with-name-that-was-inserted-on-DOMNodeRemoved-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/remove-element-with-name-that-was-inserted-on-DOMNodeRemoved-expected.txt 2014-05-18 06:11:24 UTC (rev 169007)
@@ -0,0 +1 @@
+PASS, removed element, with HTML attribute name, which was inserted on event DOMNodeRemoved.
Added: trunk/LayoutTests/fast/dom/remove-element-with-name-that-was-inserted-on-DOMNodeRemoved.html (0 => 169007)
--- trunk/LayoutTests/fast/dom/remove-element-with-name-that-was-inserted-on-DOMNodeRemoved.html (rev 0)
+++ trunk/LayoutTests/fast/dom/remove-element-with-name-that-was-inserted-on-DOMNodeRemoved.html 2014-05-18 06:11:24 UTC (rev 169007)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head></head> <!-- This element isn't necessary, but makes it straightforward to reason about the test when debugging it. -->
+<body data-debug-name="declarativeBody"></body> <!-- This element isn't necessary, but makes it straightforward to reason about the test when debugging it. -->
+<!-- Notice a <script> is only executed once. -->
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+var savedDocumentElement;
+function appendBodyElementToSavedDocument()
+{
+ document.removeEventListener("DOMNodeRemoved", appendBodyElementToSavedDocument, false);
+ savedDocumentElement.appendChild(document.createElement("body")).setAttribute("data-debug-name", "programmaticBody");
+}
+
+function insertSavedDocument()
+{
+ document.appendChild(savedDocumentElement); // Will execute <script id="script2">.
+}
+
+savedDocumentElement = document.documentElement;
+document.addEventListener("DOMNodeRemoved", appendBodyElementToSavedDocument, false);
+document.removeChild(savedDocumentElement); // Prevents <script id="script2"> from running since it won't be in the document when we fall off the end of this <script>.
+window.setTimeout(insertSavedDocument, 0);
+</script>
+<!-- This must be in its own <script> so that we execute it (for the first time) when we re-insert it into the document in insertSavedDocument(). -->
+<script id="script2">
+// [1] The array |elements| will either have the form {..., <body id="declarativeBody">, ...} or {..., <body id="declarativeBody">, ..., <body id="programmaticBody">, ...}.
+// The former will cause an assertion failure when we execute [2].
+var elements = document.querySelectorAll("*");
+for (var i = 0; i < elements.length; ++i)
+ elements[i].setAttribute("name", elements[i].nodeName);
+
+// [2] Destroy the entire document, including <body data-debug-name="declarativeBody"> and <body data-debug-name="programmaticBody">. Moving the
+// following line to its own <script> and altering the execution time of this page (say, by stepping through code in a WebCore debug session)
+// tends to affect the result of |elements| (see remark [1]).
+document.write("PASS, removed element, with HTML attribute name, which was inserted on event DOMNodeRemoved.");
+</script>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (169006 => 169007)
--- trunk/Source/WebCore/ChangeLog 2014-05-18 05:29:36 UTC (rev 169006)
+++ trunk/Source/WebCore/ChangeLog 2014-05-18 06:11:24 UTC (rev 169007)
@@ -1,3 +1,17 @@
+2014-05-17 Maciej Stachowiak <[email protected]>
+
+ Don't attempt to update id or name for nodes that are already removed
+ https://bugs.webkit.org/show_bug.cgi?id=133041
+
+ Reviewed by Sam Weinig.
+
+ Tests: fast/dom/remove-element-with-id-that-was-inserted-on-DOMNodeRemoved.html
+ fast/dom/remove-element-with-name-that-was-inserted-on-DOMNodeRemoved.html
+
+ * dom/Element.cpp:
+ (WebCore::Element::removedFrom): Skip updating ids and names for an element not
+ in a treescope, as we already do for elements not in a document.
+
2014-05-17 Alexey Proskuryakov <[email protected]>
REGRESSION (NetworkProcess): Trying to use appcache fallback crashes in ApplicationCacheHost::scheduleLoadFallbackResourceFromApplicationCache
Modified: trunk/Source/WebCore/dom/Element.cpp (169006 => 169007)
--- trunk/Source/WebCore/dom/Element.cpp 2014-05-18 05:29:36 UTC (rev 169006)
+++ trunk/Source/WebCore/dom/Element.cpp 2014-05-18 06:11:24 UTC (rev 169007)
@@ -1387,7 +1387,7 @@
if (insertionPoint.isInTreeScope()) {
TreeScope* oldScope = &insertionPoint.treeScope();
HTMLDocument* oldDocument = inDocument() && oldScope->documentScope().isHTMLDocument() ? toHTMLDocument(&oldScope->documentScope()) : nullptr;
- if (oldScope != &treeScope())
+ if (oldScope != &treeScope() || !isInTreeScope())
oldScope = nullptr;
const AtomicString& idValue = getIdAttribute();