Title: [123359] trunk
Revision
123359
Author
[email protected]
Date
2012-07-23 12:26:35 -0700 (Mon, 23 Jul 2012)

Log Message

REGRESSION(r123281): childNodes sometimes returns wrong nodes
https://bugs.webkit.org/show_bug.cgi?id=92014

Reviewed by Anders Carlsson.

Source/WebCore: 

The bug was caused by a typo in itemBeforeOrAfter. Namely, it should have been calling firstNode as
firstNode(forward, rootNode(), shouldOnlyIncludeDirectChildren()),
NOT firstNode(forward, rootNode(), previous)
as evident from the argument list of the function.

Test: fast/dom/NodeList/childNodes-reverse-iteration.html

* html/HTMLCollection.cpp:
(WebCore::DynamicNodeListCacheBase::itemBeforeOrAfter):

LayoutTests: 

Added an integration regression test that caught this bug.

* fast/dom/NodeList/childNodes-reverse-iteration-expected.txt: Added.
* fast/dom/NodeList/childNodes-reverse-iteration.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123358 => 123359)


--- trunk/LayoutTests/ChangeLog	2012-07-23 18:58:00 UTC (rev 123358)
+++ trunk/LayoutTests/ChangeLog	2012-07-23 19:26:35 UTC (rev 123359)
@@ -1,3 +1,15 @@
+2012-07-23  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r123281): childNodes sometimes returns wrong nodes
+        https://bugs.webkit.org/show_bug.cgi?id=92014
+
+        Reviewed by Anders Carlsson.
+
+        Added an integration regression test that caught this bug.
+
+        * fast/dom/NodeList/childNodes-reverse-iteration-expected.txt: Added.
+        * fast/dom/NodeList/childNodes-reverse-iteration.html: Added.
+
 2012-07-23  Luciano Wolf  <[email protected]>
 
         [Qt] animations needs rebaseline after new test fonts

Added: trunk/LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration-expected.txt (0 => 123359)


--- trunk/LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration-expected.txt	2012-07-23 19:26:35 UTC (rev 123359)
@@ -0,0 +1,9 @@
+This is an integration test for childNodes. You should see 1 through 5 below.
+
+1
+2
+3
+4
+5
+PASS node.innerText is '1\n2\n3\n4\n5\n'
+

Added: trunk/LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration.html (0 => 123359)


--- trunk/LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration.html	2012-07-23 19:26:35 UTC (rev 123359)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This is an integration test for childNodes. You should see 1 through 5 below.</p>
+<pre></pre>
+<div id="console"></div>
+<script src=""
+<script>
+
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var node = document.querySelector('pre');
+var failed = false;
+for (var j = 0; j < 5; ++j) {
+    var child = document.createElement('div');
+    child.innerHTML = j + 1;
+    node.appendChild(child);
+    for (var i = node.childNodes.length - 1; i >= 0; --i) {
+        var actual = node.childNodes[i] ? node.childNodes[i].innerHTML : undefined;
+        if (actual != i + 1) {
+            testFailed('Got ' + actual + ' on ' + (i + 1) + 'st/nd/th child after adding ' + (j + 1) + 'st/nd/th child.');
+            failed  = true;
+        }
+    }
+}
+
+shouldBe("node.innerText", "'1\\n2\\n3\\n4\\n5\\n'");
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (123358 => 123359)


--- trunk/Source/WebCore/ChangeLog	2012-07-23 18:58:00 UTC (rev 123358)
+++ trunk/Source/WebCore/ChangeLog	2012-07-23 19:26:35 UTC (rev 123359)
@@ -1,3 +1,20 @@
+2012-07-23  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r123281): childNodes sometimes returns wrong nodes
+        https://bugs.webkit.org/show_bug.cgi?id=92014
+
+        Reviewed by Anders Carlsson.
+
+        The bug was caused by a typo in itemBeforeOrAfter. Namely, it should have been calling firstNode as
+        firstNode(forward, rootNode(), shouldOnlyIncludeDirectChildren()),
+        NOT firstNode(forward, rootNode(), previous)
+        as evident from the argument list of the function.
+
+        Test: fast/dom/NodeList/childNodes-reverse-iteration.html
+
+        * html/HTMLCollection.cpp:
+        (WebCore::DynamicNodeListCacheBase::itemBeforeOrAfter):
+
 2012-07-23  Steve VanDeBogart  <[email protected]>
 
         Chrome/Skia: PDF print output does not have clickable links.

Modified: trunk/Source/WebCore/html/HTMLCollection.cpp (123358 => 123359)


--- trunk/Source/WebCore/html/HTMLCollection.cpp	2012-07-23 18:58:00 UTC (rev 123358)
+++ trunk/Source/WebCore/html/HTMLCollection.cpp	2012-07-23 19:26:35 UTC (rev 123359)
@@ -288,7 +288,7 @@
     if (LIKELY(!!previous)) // Without this LIKELY, length() and item() can be 10% slower.
         current = nextNode<forward>(rootNode(), previous, shouldOnlyIncludeDirectChildren());
     else
-        current = firstNode(forward, rootNode(), previous);
+        current = firstNode(forward, rootNode(), shouldOnlyIncludeDirectChildren());
 
     if (type() == NodeListCollectionType && shouldOnlyIncludeDirectChildren()) // ChildNodeList
         return current;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to