Changeset 60606 in webkit


Ignore:
Timestamp:
Jun 2, 2010 10:25:14 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-06-02 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

REGRESSION(60409): document.write is not synchronous when using the HTML5 parser
https://bugs.webkit.org/show_bug.cgi?id=40047

The HTML5 spec states that we should "spin the event loop" while
waiting for stylesheets to load. Currently we do that by yielding
out of the parser when stylesheets are loading. Because it was easy
we made inline <scripts> yield for stylesheet loads as well. However,
this caused document.write() to return after encountering the first
inline <script> tag in many cases which is incorrect. document.write
is supposed to block until the entire document is parsed (including)
executing inline script tags. To match the exiting parser, we'll just
make inline <script> tags not block on stylesheets for now.

This is tested by WebCore/benchmarks/html-parser.html as well
as likely several other tests in LayoutTests which we haven't
triaged yet.

  • html/HTML5ScriptRunner.cpp: (WebCore::HTML5ScriptRunner::executeScript):
    • ASSERT that either stylesheets have loaded or we're executing an inline <script> tag.

(WebCore::HTML5ScriptRunner::runScript):

  • Remove the code to block inline <script> tags on stylesheet loads.
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r60605 r60606  
     12010-06-02  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        REGRESSION(60409): document.write is not synchronous when using the HTML5 parser
     6        https://bugs.webkit.org/show_bug.cgi?id=40047
     7
     8        The HTML5 spec states that we should "spin the event loop" while
     9        waiting for stylesheets to load.  Currently we do that by yielding
     10        out of the parser when stylesheets are loading.  Because it was easy
     11        we made inline <scripts> yield for stylesheet loads as well.  However,
     12        this caused document.write() to return after encountering the first
     13        inline <script> tag in many cases which is incorrect.  document.write
     14        is supposed to block until the entire document is parsed (including)
     15        executing inline script tags.  To match the exiting parser, we'll just
     16        make inline <script> tags not block on stylesheets for now.
     17
     18        This is tested by WebCore/benchmarks/html-parser.html as well
     19        as likely several other tests in LayoutTests which we haven't
     20        triaged yet.
     21
     22        * html/HTML5ScriptRunner.cpp:
     23        (WebCore::HTML5ScriptRunner::executeScript):
     24         - ASSERT that either stylesheets have loaded or we're executing an
     25           inline <script> tag.
     26        (WebCore::HTML5ScriptRunner::runScript):
     27         - Remove the code to block inline <script> tags on stylesheet loads.
     28
    1292010-06-02  MORITA Hajime  <morrita@google.com>
    230
  • trunk/WebCore/html/HTML5ScriptRunner.cpp

    r60553 r60606  
    128128void HTML5ScriptRunner::executeScript(Element* element, const ScriptSourceCode& sourceCode)
    129129{
     130    // FIXME: We do not block inline <script> tags on stylesheets for now.
     131    // When we do,  || !element->hasAttribute(srcAttr) should be removed from
     132    // the ASSERT below.  See https://bugs.webkit.org/show_bug.cgi?id=40047
     133    ASSERT(m_document->haveStylesheetsLoaded() || !element->hasAttribute(srcAttr));
    130134    ScriptElement* scriptElement = toScriptElement(element);
    131135    ASSERT(scriptElement);
     
    235239        // FIXME: Handle defer and async
    236240        requestScript(script);
    237     } else if (!m_document->haveStylesheetsLoaded()) {
    238         m_parsingBlockingScript.element = script;
    239         m_parsingBlockingScript.startingLineNumber = startingLineNumber;
    240241    } else {
     242        // FIXME: We do not block inline <script> tags on stylesheets to match the
     243        // old parser for now.  See https://bugs.webkit.org/show_bug.cgi?id=40047
    241244        ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), startingLineNumber);
    242245        executeScript(script, sourceCode);
Note: See TracChangeset for help on using the changeset viewer.