Skip to content
  • ggaren@apple.com's avatar
    If Node X is reachable from JavaScript, all Nodes in the same tree should be kept alive · e0fc2216
    ggaren@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=88834
    
    Reviewed by Gavin Barraclough.
    
    Source/WebCore: 
    
    * bindings/js/JSNodeCustom.cpp:
    (WebCore::isObservable): Clarified this comment, since it seems to have
    misled some folks. 
    
    * bindings/js/JSNodeCustom.h:
    (WebCore::willCreatePossiblyOrphanedTreeByRemoval): New helper function
    to ensure that a disconnected tree is visible to JavaScript.
    
    * bindings/js/ScriptState.cpp:
    (WebCore::mainWorldScriptState): Need to check for null because a document's
    frame can be null.
    
    * dom/ContainerNode.cpp:
    (WebCore::dispatchChildRemovalEvents): When we remove a subtree from the
    document, we sever the reference that JavaScript previously held by
    referencing its root. So, we give JavaScript an opportunity to establish
    a reference to the new root.
    
    LayoutTests: 
    
    * fast/dom/gc-12-expected.txt: Added.
    * fast/dom/gc-12.html: Added. Test case matches an example cited by
    Kentaro Hara <haraken@chromium.org> in bugzilla.
    
    * fast/dom/gc-3-expected.txt:
    * fast/dom/gc-3.html:
    * fast/dom/gc-5-expected.txt:
    * fast/dom/gc-5.html: Updated these tests to reflect new expected behavior.
    We've decided that disconnected trees should persist in memory. This risks
    a programmer accidentally retaining more memory than expected, but it
    also makes the API more obvious.
    
    * fast/dom/gc-dom-tree-lifetime-expected.txt: Added.
    * fast/dom/gc-dom-tree-lifetime.html: Added. Test case written by
    Kentaro Hara <haraken@chromium.org>.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130584 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    e0fc2216