Title: [124282] trunk
Revision
124282
Author
[email protected]
Date
2012-07-31 19:03:23 -0700 (Tue, 31 Jul 2012)

Log Message

REGRESSION(r120979): Node list returned by getElementsByTagNameNS isn't invalidated when children changes
https://bugs.webkit.org/show_bug.cgi?id=92705

Reviewed by Abhishek Arya.

Source/WebCore: 

The bug was caused by a typo in NodeListsNodeData::invalidateCaches. We need to invalidate
tag name node lists when child nodes change and not when attributes change.

Test: fast/dom/NodeList/nodelist-namespace-invalidation.html

* dom/Node.cpp:
(WebCore::NodeListsNodeData::invalidateCaches):

LayoutTests: 

Add a regression test to ensure node lists returned by getElementsByTagNameNS are invalidated
when child nodes are added or removed.

* fast/dom/NodeList/nodelist-namespace-invalidation-expected.txt: Added.
* fast/dom/NodeList/nodelist-namespace-invalidation.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (124281 => 124282)


--- trunk/LayoutTests/ChangeLog	2012-08-01 01:51:56 UTC (rev 124281)
+++ trunk/LayoutTests/ChangeLog	2012-08-01 02:03:23 UTC (rev 124282)
@@ -1,3 +1,16 @@
+2012-07-30  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r120979): Node list returned by getElementsByTagNameNS isn't invalidated when children changes
+        https://bugs.webkit.org/show_bug.cgi?id=92705
+
+        Reviewed by Abhishek Arya.
+
+        Add a regression test to ensure node lists returned by getElementsByTagNameNS are invalidated
+        when child nodes are added or removed.
+
+        * fast/dom/NodeList/nodelist-namespace-invalidation-expected.txt: Added.
+        * fast/dom/NodeList/nodelist-namespace-invalidation.html: Added.
+
 2012-07-31  Tony Chang  <[email protected]>
 
         flexbox should avoid floats

Added: trunk/LayoutTests/fast/dom/NodeList/nodelist-namespace-invalidation-expected.txt (0 => 124282)


--- trunk/LayoutTests/fast/dom/NodeList/nodelist-namespace-invalidation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/nodelist-namespace-invalidation-expected.txt	2012-08-01 02:03:23 UTC (rev 124282)
@@ -0,0 +1,10 @@
+This tests that node lists returned by getElementsByTagNameNS are invalidated upon child node changes.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS appendImageWithId('firstImage'); nodeList = container.getElementsByTagNameNS(namespace, 'img'); nodeList.item(0).id is 'firstImage'
+PASS nodeList.length is 1
+PASS appendImageWithId('secondImage'); container.removeChild(container.firstChild); nodeList.item(0).id is 'secondImage'
+PASS nodeList.length is 1
+

Added: trunk/LayoutTests/fast/dom/NodeList/nodelist-namespace-invalidation.html (0 => 124282)


--- trunk/LayoutTests/fast/dom/NodeList/nodelist-namespace-invalidation.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/nodelist-namespace-invalidation.html	2012-08-01 02:03:23 UTC (rev 124282)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+
+description("This tests that node lists returned by getElementsByTagNameNS are invalidated upon child node changes.");
+
+var container = document.createElement('div');
+
+function appendImageWithId(id) {
+    container.appendChild(document.createElement('img'));
+    container.lastChild.id = id;
+}
+
+var nodeList;
+var namespace = document.body.namespaceURI;
+shouldBe("appendImageWithId('firstImage'); nodeList = container.getElementsByTagNameNS(namespace, 'img'); nodeList.item(0).id", "'firstImage'");
+shouldBe("nodeList.length", "1");
+shouldBe("appendImageWithId('secondImage'); container.removeChild(container.firstChild); nodeList.item(0).id", "'secondImage'");
+shouldBe("nodeList.length", "1");
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (124281 => 124282)


--- trunk/Source/WebCore/ChangeLog	2012-08-01 01:51:56 UTC (rev 124281)
+++ trunk/Source/WebCore/ChangeLog	2012-08-01 02:03:23 UTC (rev 124282)
@@ -1,3 +1,18 @@
+2012-07-30  Ryosuke Niwa  <[email protected]>
+
+        REGRESSION(r120979): Node list returned by getElementsByTagNameNS isn't invalidated when children changes
+        https://bugs.webkit.org/show_bug.cgi?id=92705
+
+        Reviewed by Abhishek Arya.
+
+        The bug was caused by a typo in NodeListsNodeData::invalidateCaches. We need to invalidate
+        tag name node lists when child nodes change and not when attributes change.
+
+        Test: fast/dom/NodeList/nodelist-namespace-invalidation.html
+
+        * dom/Node.cpp:
+        (WebCore::NodeListsNodeData::invalidateCaches):
+
 2012-07-31  Tony Chang  <[email protected]>
 
         flexbox should avoid floats

Modified: trunk/Source/WebCore/dom/Node.cpp (124281 => 124282)


--- trunk/Source/WebCore/dom/Node.cpp	2012-08-01 01:51:56 UTC (rev 124281)
+++ trunk/Source/WebCore/dom/Node.cpp	2012-08-01 02:03:23 UTC (rev 124282)
@@ -2266,7 +2266,7 @@
     for (NodeListNameCacheMap::const_iterator it = m_nameCaches.begin(); it != nameCacheEnd; ++it)
         it->second->invalidateCache(attrName);
 
-    if (!attrName)
+    if (attrName)
         return;
 
     TagNodeListCacheNS::iterator tagCacheEnd = m_tagNodeListCacheNS.end();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to