Changeset 74752 in webkit


Ignore:
Timestamp:
Dec 29, 2010 12:39:58 PM (13 years ago)
Author:
tonyg@chromium.org
Message:

2010-12-29 Tony Gentilcore <tonyg@chromium.org>

Reviewed by Eric Seidel.

Assertion failure: element->inDocument() in AsyncScriptRunner::executeScriptSoon()
https://bugs.webkit.org/show_bug.cgi?id=51067

  • fast/dom/HTMLScriptElement/move-in-beforeload-expected.txt: Added.
  • fast/dom/HTMLScriptElement/move-in-beforeload.html: Added.
  • fast/dom/HTMLScriptElement/remove-in-beforeload-expected.txt: Added.
  • fast/dom/HTMLScriptElement/remove-in-beforeload.html: Added.

2010-12-29 Tony Gentilcore <tonyg@chromium.org>

Reviewed by Eric Seidel.

Assertion failure: element->inDocument() in AsyncScriptRunner::executeScriptSoon()
https://bugs.webkit.org/show_bug.cgi?id=51067

Typically when a script element is removed from the document, the cached script
client is removed. However, during the before load event, the cached script client
hasn't been created yet so it can't be removed.

This patch handles that case by explicitly checking if the script element was
removed during the beforeload event. Also, it avoids caching the Document references
over the arbitrary script execution in the before load event.

Test: fast/dom/HTMLScriptElement/move-in-beforeload.html

fast/dom/HTMLScriptElement/remove-in-beforeload.html

  • dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript):
Location:
trunk
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r74750 r74752  
     12010-12-29  Tony Gentilcore  <tonyg@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Assertion failure: element->inDocument() in AsyncScriptRunner::executeScriptSoon()
     6        https://bugs.webkit.org/show_bug.cgi?id=51067
     7
     8        * fast/dom/HTMLScriptElement/move-in-beforeload-expected.txt: Added.
     9        * fast/dom/HTMLScriptElement/move-in-beforeload.html: Added.
     10        * fast/dom/HTMLScriptElement/remove-in-beforeload-expected.txt: Added.
     11        * fast/dom/HTMLScriptElement/remove-in-beforeload.html: Added.
     12
    1132010-12-29  Mihai Parparita  <mihaip@chromium.org>
    214
  • trunk/WebCore/ChangeLog

    r74745 r74752  
     12010-12-29  Tony Gentilcore  <tonyg@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Assertion failure: element->inDocument() in AsyncScriptRunner::executeScriptSoon()
     6        https://bugs.webkit.org/show_bug.cgi?id=51067
     7
     8        Typically when a script element is removed from the document, the cached script
     9        client is removed. However, during the before load event, the cached script client
     10        hasn't been created yet so it can't be removed.
     11
     12        This patch handles that case by explicitly checking if the script element was
     13        removed during the beforeload event. Also, it avoids caching the Document references
     14        over the arbitrary script execution in the before load event.
     15
     16        Test: fast/dom/HTMLScriptElement/move-in-beforeload.html
     17              fast/dom/HTMLScriptElement/remove-in-beforeload.html
     18
     19        * dom/ScriptElement.cpp:
     20        (WebCore::ScriptElement::requestScript):
     21
    1222010-12-29  Alexander Pavlov  <apavlov@chromium.org>
    223
  • trunk/WebCore/dom/ScriptElement.cpp

    r73436 r74752  
    146146void ScriptElement::requestScript(const String& sourceUrl)
    147147{
    148     Document* document = m_element->document();
    149 
    150148    // FIXME: Eventually we'd like to evaluate scripts which are inserted into a
    151149    // viewless document but this'll do for now.
    152150    // See http://bugs.webkit.org/show_bug.cgi?id=5727
    153     if (!document->frame())
    154         return;
    155 
     151    if (!m_element->document()->frame())
     152        return;
     153
     154    RefPtr<Document> originalDocument = m_element->document();
    156155    if (!m_element->dispatchBeforeLoadEvent(sourceUrl))
    157156        return;
     157    if (!m_element->inDocument() || m_element->document() != originalDocument)
     158        return;
    158159
    159160    ASSERT(!m_cachedScript);
    160     m_cachedScript = document->cachedResourceLoader()->requestScript(sourceUrl, scriptCharset());
     161    m_cachedScript = m_element->document()->cachedResourceLoader()->requestScript(sourceUrl, scriptCharset());
    161162    m_isExternalScript = true;
    162163
Note: See TracChangeset for help on using the changeset viewer.