WebCore/ChangeLog

 12010-06-02 Eric Seidel <eric@webkit.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 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-01 Sheriff Bot <webkit.review.bot@gmail.com>
230
331 Unreviewed, rolling out r60530.

WebCore/html/HTML5ScriptRunner.cpp

@@void HTML5ScriptRunner::executePendingScript()
127127
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);
132136 if (!scriptElement->shouldExecuteAsJavaScript())

@@void HTML5ScriptRunner::runScript(Element* script)
234238 if (script->hasAttribute(srcAttr)) {
235239 // FIXME: Handle defer and async
236240 requestScript(script);
237  } else if (!m_document->haveStylesheetsLoaded()) {
238  m_parsingBlockingScript.element = script;
 241 // FIXME: We do not block inline <script> tags on stylesheets to match the
 242 // old parser for now. See https://bugs.webkit.org/show_bug.cgi?id=40047
 243 // } else if (!m_document->haveStylesheetsLoaded()) {
 244 // m_parsingBlockingScript.element = script;
239245 } else {
240246 // FIXME: Need a line numbers implemenation.
241247 ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), 0);