Reviewed by Kevin.
Fix <rdar://problem/
5444866>
REGRESSION: missing text in Acrobat "Getting Started" screen due to change in load ordering of large resources
Make external scripts loaded using file: wait until all style sheet loads have completed before executing.
Fixes a class of problems where there is a dependency between script and stylesheet and results would effectively
get randomized based on which order the resources arrived. In Tiger file loads were effectively serialized by
lower level components, which is why this regressed.
Test: http/tests/local/stylesheet-and-script-load-order.html
* dom/Document.cpp:
(WebCore::Document::removePendingSheet):
* dom/Tokenizer.h:
(WebCore::Tokenizer::executeScriptsWaitingForStylesheets):
* html/HTMLTokenizer.cpp:
(WebCore::HTMLTokenizer::HTMLTokenizer):
(WebCore::HTMLTokenizer::begin):
(WebCore::HTMLTokenizer::executeScriptsWaitingForStylesheets):
(WebCore::HTMLTokenizer::notifyFinished):
* html/HTMLTokenizer.h:
LayoutTests:
Reviewed by Kevin.
Test for <rdar://problem/
5444866>
REGRESSION: missing text in Acrobat "Getting Started" screen due to change in load ordering of large resources
* http/tests/local/stylesheet-and-script-load-order-expected.txt: Added.
* http/tests/local/stylesheet-and-script-load-order.html: Added.
* http/tests/local/stylesheet-dependent.js: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25466
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-09-10 Antti Koivisto <antti@apple.com>
+
+ Reviewed by Kevin.
+
+ Test for <rdar://problem/5444866>
+ REGRESSION: missing text in Acrobat "Getting Started" screen due to change in load ordering of large resources
+
+ * http/tests/local/stylesheet-and-script-load-order-expected.txt: Added.
+ * http/tests/local/stylesheet-and-script-load-order.html: Added.
+ * http/tests/local/stylesheet-dependent.js: Added.
+
2007-09-09 Sam Weinig <sam@webkit.org>
Disable more occasionally failing tests.
--- /dev/null
+Test that stylesheet loads complete before external scripts are executed.
+
+PASS
--- /dev/null
+<html>
+<head>
+ <script>
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+ </script>
+ <link rel=stylesheet href="http://127.0.0.1:8000/local/slow-css-pass.cgi">
+</head>
+<body>
+ <p>Test that stylesheet loads complete before external scripts are executed.</p>
+ <script src=stylesheet-dependent.js></script>
+</body>
+</html>
--- /dev/null
+document.write(document.styleSheets[0] ? "PASS" : "FAIL");
+2007-09-10 Antti Koivisto <antti@apple.com>
+
+ Reviewed by Kevin.
+
+ Fix <rdar://problem/5444866>
+ REGRESSION: missing text in Acrobat "Getting Started" screen due to change in load ordering of large resources
+
+ Make external scripts loaded using file: wait until all style sheet loads have completed before executing.
+ Fixes a class of problems where there is a dependency between script and stylesheet and results would effectively
+ get randomized based on which order the resources arrived. In Tiger file loads were effectively serialized by
+ lower level components, which is why this regressed.
+
+ Test: http/tests/local/stylesheet-and-script-load-order.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::removePendingSheet):
+ * dom/Tokenizer.h:
+ (WebCore::Tokenizer::executeScriptsWaitingForStylesheets):
+ * html/HTMLTokenizer.cpp:
+ (WebCore::HTMLTokenizer::HTMLTokenizer):
+ (WebCore::HTMLTokenizer::begin):
+ (WebCore::HTMLTokenizer::executeScriptsWaitingForStylesheets):
+ (WebCore::HTMLTokenizer::notifyFinished):
+ * html/HTMLTokenizer.h:
+
2007-09-08 David Smith <catfish.man@gmail.com>
Reviewed by Maciej Stachowiak.
#endif
updateStyleSelector();
+
+ if (!m_pendingStylesheets && m_tokenizer)
+ m_tokenizer->executeScriptsWaitingForStylesheets();
if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad && m_frame)
m_frame->loader()->gotoAnchor();
virtual int lineNumber() const { return -1; }
virtual int columnNumber() const { return -1; }
+
+ virtual void executeScriptsWaitingForStylesheets() {}
protected:
// The tokenizer has buffers, so parsing may continue even after
, scriptCodeResync(0)
, m_executingScript(0)
, m_requestingScript(false)
+ , m_hasScriptsWaitingForStylesheets(false)
, m_timer(this, &HTMLTokenizer::timerFired)
, m_doc(doc)
, parser(new HTMLParser(doc, reportErrors))
, scriptCodeResync(0)
, m_executingScript(0)
, m_requestingScript(false)
+ , m_hasScriptsWaitingForStylesheets(false)
, m_timer(this, &HTMLTokenizer::timerFired)
, m_doc(doc)
, parser(0)
, scriptCodeResync(0)
, m_executingScript(0)
, m_requestingScript(false)
+ , m_hasScriptsWaitingForStylesheets(false)
, m_timer(this, &HTMLTokenizer::timerFired)
, m_doc(frag->document())
, inWrite(false)
{
m_executingScript = 0;
m_requestingScript = false;
+ m_hasScriptsWaitingForStylesheets = false;
m_state.setLoadingExtScript(false);
reset();
size = 254;
scriptCode = static_cast<UChar*>(fastRealloc(scriptCode, newSize * sizeof(UChar)));
scriptCodeMaxSize = newSize;
}
+
+void HTMLTokenizer::executeScriptsWaitingForStylesheets()
+{
+ ASSERT(m_doc->haveStylesheetsLoaded());
+
+ if (m_hasScriptsWaitingForStylesheets)
+ notifyFinished(0);
+}
void HTMLTokenizer::notifyFinished(CachedResource*)
{
#endif
ASSERT(!pendingScripts.isEmpty());
+
+ // Make scripts loaded from file URLs wait for stylesheets to match Tiger behavior where
+ // file loads were serialized in lower level.
+ // FIXME: this should really be done for all script loads or the same effect should be achieved by other
+ // means, like javascript suspend/resume
+ m_hasScriptsWaitingForStylesheets = !m_doc->haveStylesheetsLoaded() && pendingScripts.head()->url().startsWith("file:", false);
+ if (m_hasScriptsWaitingForStylesheets)
+ return;
+
bool finished = false;
while (!finished && pendingScripts.head()->isLoaded()) {
#ifdef TOKEN_DEBUG
int* lineNumberPtr() { return &lineno; }
bool processingContentWrittenByScript() const { return src.excludeLineNumbers(); }
+
+ virtual void executeScriptsWaitingForStylesheets();
private:
class State;
RefPtr<Node> scriptNode;
bool m_requestingScript;
+ bool m_hasScriptsWaitingForStylesheets;
// if we found one broken comment, there are most likely others as well
// store a flag to get rid of the O(n^2) behaviour in such a case.