Title: [121496] trunk
Revision
121496
Author
[email protected]
Date
2012-06-28 18:13:44 -0700 (Thu, 28 Jun 2012)

Log Message

[V8] NodeList wrappers are not kept alive as needed
https://bugs.webkit.org/show_bug.cgi?id=90194

Reviewed by Ojan Vafai.

Source/WebCore:

We need to add custom reachability code for DynamicNodeLists. If the owner of
a DynamicNodeList is reachable then the DynamicNodeList must also be reachable.

Test: fast/dom/NodeList/nodelist-reachable.html

* bindings/v8/custom/V8NodeListCustom.cpp:
(WebCore::V8NodeList::visitDOMWrapper): AddImplicitReferences from the owner wrapper.
(WebCore):
* dom/NodeList.idl:

LayoutTests:

* fast/dom/NodeList/nodelist-reachable-expected.txt: Added.
* fast/dom/NodeList/nodelist-reachable.html: Added.
* platform/chromium/fast/dom/NodeList/nodelist-reachable-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (121495 => 121496)


--- trunk/LayoutTests/ChangeLog	2012-06-29 00:59:37 UTC (rev 121495)
+++ trunk/LayoutTests/ChangeLog	2012-06-29 01:13:44 UTC (rev 121496)
@@ -1,3 +1,14 @@
+2012-06-28  Erik Arvidsson  <[email protected]>
+
+        [V8] NodeList wrappers are not kept alive as needed
+        https://bugs.webkit.org/show_bug.cgi?id=90194
+
+        Reviewed by Ojan Vafai.
+
+        * fast/dom/NodeList/nodelist-reachable-expected.txt: Added.
+        * fast/dom/NodeList/nodelist-reachable.html: Added.
+        * platform/chromium/fast/dom/NodeList/nodelist-reachable-expected.txt: Added.
+
 2012-06-28  Hayato Ito  <[email protected]>
 
         Add a test for a 'user-modify' css property of distributed nodes.

Added: trunk/LayoutTests/fast/dom/NodeList/nodelist-reachable-expected.txt (0 => 121496)


--- trunk/LayoutTests/fast/dom/NodeList/nodelist-reachable-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/nodelist-reachable-expected.txt	2012-06-29 01:13:44 UTC (rev 121496)
@@ -0,0 +1,10 @@
+PASS document.body.childNodes.customProperty is 1
+PASS document.getElementsByClassName("class").customProperty is 2
+PASS document.getElementsByName("name").customProperty is 3
+PASS document.getElementsByTagName("body").customProperty is 4
+PASS document.querySelector("form").elements["radios"].customProperty is 5
+PASS document.querySelector("input").labels.customProperty is 6
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Added: trunk/LayoutTests/fast/dom/NodeList/nodelist-reachable.html (0 => 121496)


--- trunk/LayoutTests/fast/dom/NodeList/nodelist-reachable.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/NodeList/nodelist-reachable.html	2012-06-29 01:13:44 UTC (rev 121496)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<body>
+<form>
+<input name="radios" type="radio">
+<input name="radios" type="radio">
+</form>
+<script src=""
+<script>
+
+var nodeListKind = {
+    ChildNodeListType: 'document.body.childNodes',
+    ClassNodeListType: 'document.getElementsByClassName("class")',
+    NameNodeListType: 'document.getElementsByName("name")',
+    TagNodeListType: 'document.getElementsByTagName("body")',
+    RadioNodeListType: 'document.querySelector("form").elements["radios"]',
+    LabelsNodeListType: 'document.querySelector("input").labels',
+    // Microdata is not enabled.
+    // MicroDataItemListType: 'document.getItems("items")',
+};
+
+var i = 1;
+for (var kind in nodeListKind) {
+    var code = nodeListKind[kind];
+    eval(code).customProperty = i;
+    gc();
+    shouldBe(code + '.customProperty', '' + i++);
+}
+
+</script>
+<script src=""
+</body>

Added: trunk/LayoutTests/platform/chromium/fast/dom/NodeList/nodelist-reachable-expected.txt (0 => 121496)


--- trunk/LayoutTests/platform/chromium/fast/dom/NodeList/nodelist-reachable-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/dom/NodeList/nodelist-reachable-expected.txt	2012-06-29 01:13:44 UTC (rev 121496)
@@ -0,0 +1,10 @@
+PASS document.body.childNodes.customProperty is 1
+PASS document.getElementsByClassName("class").customProperty is 2
+PASS document.getElementsByName("name").customProperty is 3
+PASS document.getElementsByTagName("body").customProperty is 4
+FAIL document.querySelector("form").elements["radios"].customProperty should be 5 (of type number). Was undefined (of type undefined).
+PASS document.querySelector("input").labels.customProperty is 6
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Modified: trunk/Source/WebCore/ChangeLog (121495 => 121496)


--- trunk/Source/WebCore/ChangeLog	2012-06-29 00:59:37 UTC (rev 121495)
+++ trunk/Source/WebCore/ChangeLog	2012-06-29 01:13:44 UTC (rev 121496)
@@ -1,3 +1,20 @@
+2012-06-28  Erik Arvidsson  <[email protected]>
+
+        [V8] NodeList wrappers are not kept alive as needed
+        https://bugs.webkit.org/show_bug.cgi?id=90194
+
+        Reviewed by Ojan Vafai.
+
+        We need to add custom reachability code for DynamicNodeLists. If the owner of
+        a DynamicNodeList is reachable then the DynamicNodeList must also be reachable.
+
+        Test: fast/dom/NodeList/nodelist-reachable.html
+
+        * bindings/v8/custom/V8NodeListCustom.cpp:
+        (WebCore::V8NodeList::visitDOMWrapper): AddImplicitReferences from the owner wrapper.
+        (WebCore):
+        * dom/NodeList.idl:
+
 2012-06-28  Elliott Sprehn  <[email protected]>
 
         frameborder="no" on frameset is ignored if border attribute set

Modified: trunk/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp (121495 => 121496)


--- trunk/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp	2012-06-29 00:59:37 UTC (rev 121495)
+++ trunk/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp	2012-06-29 01:13:44 UTC (rev 121496)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "V8NodeList.h" 
 
+#include "DynamicNodeList.h"
 #include "NodeList.h"
 #include "V8Binding.h"
 #include "V8Node.h"
@@ -59,4 +60,19 @@
     return toV8(result.release(), info.GetIsolate());
 }
 
+void V8NodeList::visitDOMWrapper(DOMDataStore* store, void* object, v8::Persistent<v8::Object> wrapper)
+{
+    NodeList* impl = static_cast<NodeList*>(object);
+    if (impl->isDynamicNodeList()) {
+        Node* owner = static_cast<DynamicNodeList*>(impl)->ownerNode();
+        if (owner) {
+            v8::Persistent<v8::Object> ownerWrapper = store->domNodeMap().get(owner);
+            if (!ownerWrapper.IsEmpty()) {
+                v8::Persistent<v8::Value> value = wrapper;
+                v8::V8::AddImplicitReferences(ownerWrapper, &value, 1);
+            }
+        }
+    }
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/NodeList.idl (121495 => 121496)


--- trunk/Source/WebCore/dom/NodeList.idl	2012-06-29 00:59:37 UTC (rev 121495)
+++ trunk/Source/WebCore/dom/NodeList.idl	2012-06-29 01:13:44 UTC (rev 121496)
@@ -21,9 +21,10 @@
 module core {
 
     interface [
-        JSCustomIsReachable,
+        CustomIsReachable,
         IndexedGetter,
-        NamedGetter
+        NamedGetter,
+        V8DependentLifetime
     ] NodeList {
 
         Node item(in [IsIndex,Optional=DefaultIsUndefined] unsigned long index);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to