Changeset 92439 in webkit


Ignore:
Timestamp:
Aug 4, 2011 6:32:24 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Bad interaction between document destruction and unload events
https://bugs.webkit.org/show_bug.cgi?id=64741

Patch by Scott Graham <scottmg@chromium.org> on 2011-08-04
Reviewed by Adam Barth.

Source/WebCore:

Three different errors triggered by this test case. The case to
consider is a subdocument with an onunload on an element, that
destroys the parent document during the onunload. One fix was a
lifetime issue fixed by a protecting RefPtr, and another was an
additional cancel of event triggers. The main fix was that during the
transition to commited state, the documentLoader is being replaced by
the provisionalDocumentLoader. But, because during firing events in
the subdocument the parent is destroyed, that subevent caused the
provisionalDocumentLoader to be detached from its frame. By marking
the page as being in committed state before the parent documentLoader
is set, this is avoided.

Test: loader/document-destruction-within-unload.html

  • dom/Document.cpp:

(WebCore::Document::implicitOpen):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::transitionToCommitted):
(WebCore::FrameLoader::detachChildren):

LayoutTests:

  • loader/document-destruction-within-unload-expected.txt: Added.
  • loader/document-destruction-within-unload.html: Added.
  • loader/resources/document-destruction-within-unload-iframe.html: Added.
  • loader/resources/document-destruction-within-unload.svg: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r92427 r92439  
     12011-08-04  Scott Graham  <scottmg@chromium.org>
     2
     3        Bad interaction between document destruction and unload events
     4        https://bugs.webkit.org/show_bug.cgi?id=64741
     5
     6        Reviewed by Adam Barth.
     7
     8        * loader/document-destruction-within-unload-expected.txt: Added.
     9        * loader/document-destruction-within-unload.html: Added.
     10        * loader/resources/document-destruction-within-unload-iframe.html: Added.
     11        * loader/resources/document-destruction-within-unload.svg: Added.
     12
    1132011-08-04  Kent Tamura  <tkent@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r92438 r92439  
     12011-08-04  Scott Graham  <scottmg@chromium.org>
     2
     3        Bad interaction between document destruction and unload events
     4        https://bugs.webkit.org/show_bug.cgi?id=64741
     5
     6        Reviewed by Adam Barth.
     7
     8        Three different errors triggered by this test case. The case to
     9        consider is a subdocument with an onunload on an element, that
     10        destroys the parent document during the onunload. One fix was a
     11        lifetime issue fixed by a protecting RefPtr, and another was an
     12        additional cancel of event triggers. The main fix was that during the
     13        transition to commited state, the documentLoader is being replaced by
     14        the provisionalDocumentLoader. But, because during firing events in
     15        the subdocument the parent is destroyed, that subevent caused the
     16        provisionalDocumentLoader to be detached from its frame. By marking
     17        the page as being in committed state before the parent documentLoader
     18        is set, this is avoided.
     19
     20        Test: loader/document-destruction-within-unload.html
     21
     22        * dom/Document.cpp:
     23        (WebCore::Document::implicitOpen):
     24        * loader/FrameLoader.cpp:
     25        (WebCore::FrameLoader::transitionToCommitted):
     26        (WebCore::FrameLoader::detachChildren):
     27
    1282011-08-04  Simon Fraser  <simon.fraser@apple.com>
    229
  • trunk/Source/WebCore/dom/Document.cpp

    r91928 r92439  
    19961996    removeChildren();
    19971997
     1998    // cancel again, as removeChildren can cause event triggers to be added
     1999    // again, which we don't want triggered on the old document.
     2000    cancelParsing();
     2001
    19982002    setCompatibilityMode(NoQuirksMode);
    19992003
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r92314 r92439  
    18351835        m_documentLoader->stopLoadingPlugIns();
    18361836
     1837    // State must be set before setting m_documentLoader to avoid
     1838    // m_provisionalDocumentLoader getting detached from the frame via a sub
     1839    // frame. See https://bugs.webkit.org/show_bug.cgi?id=64741 for more
     1840    // discussion.
     1841    setState(FrameStateCommittedPage);
    18371842    setDocumentLoader(m_provisionalDocumentLoader.get());
    18381843    setProvisionalDocumentLoader(0);
    1839     setState(FrameStateCommittedPage);
    18401844
    18411845#if ENABLE(TOUCH_EVENTS)
     
    23332337void FrameLoader::detachChildren()
    23342338{
     2339    typedef Vector<RefPtr<Frame> > FrameVector;
     2340    FrameVector protect;
     2341
    23352342    // FIXME: Is it really necessary to do this in reverse order?
    2336     Frame* previous;
    2337     for (Frame* child = m_frame->tree()->lastChild(); child; child = previous) {
    2338         previous = child->tree()->previousSibling();
    2339         child->loader()->detachFromParent();
    2340     }
     2343    for (Frame* child = m_frame->tree()->lastChild(); child; child = child->tree()->previousSibling())
     2344        protect.append(child);
     2345    for (FrameVector::iterator it = protect.begin(); it != protect.end(); ++it)
     2346        (*it)->loader()->detachFromParent();
    23412347}
    23422348
Note: See TracChangeset for help on using the changeset viewer.