Bug 91014 - Static NodeList needs to to keep item wrappers alive
Summary: Static NodeList needs to to keep item wrappers alive
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 105666 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-07-11 14:12 PDT by Erik Arvidsson
Modified: 2013-03-19 13:23 PDT (History)
6 users (show)

See Also:


Attachments
Layout test (374 bytes, text/html)
2012-07-11 14:12 PDT, Erik Arvidsson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Arvidsson 2012-07-11 14:12:22 PDT
Created attachment 151772 [details]
Layout test

Currently we do not keep the wrappers of static node lists alive. Both the JSC and V8 bindings get this wrong.

document.body.innerHTML = '<b></b>';
var elements = document.body.querySelectorAll('*');
elements[0].customProperty = 42;
document.body.textContent = '';
gc();
shouldBe('elements[0].customProperty', '42');
Comment 1 Geoffrey Garen 2012-07-16 11:50:30 PDT
Does this problem only apply to StaticNodeList? What about StaticHashSetNodeList and DynamicNodeList?

In JSC, the way to fix this is to make the node list wrapper's visit function add its document to the opaque root set. This will require giving all NodeLists, and not just DynamicNodeLists, owner document pointers.
Comment 2 Erik Arvidsson 2012-07-16 14:29:37 PDT
(In reply to comment #1)
> Does this problem only apply to StaticNodeList? What about StaticHashSetNodeList and DynamicNodeList?

Most (all?) of the DynamicNodeLists keep the wrappers alive though other means. For example the nodes in a childNodes NodeList are kept alive as long as the parent node is kept alive.
Comment 3 Geoffrey Garen 2012-07-16 14:33:55 PDT
How do they keep the parent node alive?
Comment 4 Ryosuke Niwa 2012-07-16 14:35:02 PDT
(In reply to comment #3)
> How do they keep the parent node alive?

DynamicNodeList has a RefPtr to its owner.
Comment 5 Geoffrey Garen 2012-07-16 14:46:37 PDT
But what keeps the JavaScript wrapper alive?
Comment 6 Adam Klein 2013-03-19 13:23:44 PDT
*** Bug 105666 has been marked as a duplicate of this bug. ***