- Revision
- 142200
- Author
- aba...@webkit.org
- Date
- 2013-02-07 16:24:31 -0800 (Thu, 07 Feb 2013)
Log Message
fast/parser/document-write-noscript.html fails for threaded HTML parser
https://bugs.webkit.org/show_bug.cgi?id=109237
Reviewed by Eric Seidel.
Source/WebCore:
If there are multiple calls to document.write in an external script, we
need to wait for them all to complete before invalidating the
speculative tokens. Instead of doing this when we unwind the
document.write call stack, we do this when we're about to resume
parsing after script execution.
Test: fast/parser/document-write-basic.html
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::processParsedChunkFromBackgroundParser):
(WebCore::HTMLDocumentParser::insert):
(WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution):
LayoutTests:
This tests basic document.write functionality. There doesn't appear to
be another fast/parser test that covers this basic case (although it's
convered in some more complicated test cases incidentally.)
* fast/parser/document-write-basic-expected.txt: Added.
* fast/parser/document-write-basic.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (142199 => 142200)
--- trunk/LayoutTests/ChangeLog 2013-02-08 00:18:14 UTC (rev 142199)
+++ trunk/LayoutTests/ChangeLog 2013-02-08 00:24:31 UTC (rev 142200)
@@ -1,3 +1,17 @@
+2013-02-07 Adam Barth <aba...@webkit.org>
+
+ fast/parser/document-write-noscript.html fails for threaded HTML parser
+ https://bugs.webkit.org/show_bug.cgi?id=109237
+
+ Reviewed by Eric Seidel.
+
+ This tests basic document.write functionality. There doesn't appear to
+ be another fast/parser test that covers this basic case (although it's
+ convered in some more complicated test cases incidentally.)
+
+ * fast/parser/document-write-basic-expected.txt: Added.
+ * fast/parser/document-write-basic.html: Added.
+
2013-02-07 Keishi Hattori <kei...@webkit.org>
REGRESSION (r140778): Calendar Picker doesn't open when the element has the required attribute
Added: trunk/LayoutTests/fast/parser/document-write-basic-expected.txt (0 => 142200)
--- trunk/LayoutTests/fast/parser/document-write-basic-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/parser/document-write-basic-expected.txt 2013-02-08 00:24:31 UTC (rev 142200)
@@ -0,0 +1 @@
+PASS
Added: trunk/LayoutTests/fast/parser/document-write-basic.html (0 => 142200)
--- trunk/LayoutTests/fast/parser/document-write-basic.html (rev 0)
+++ trunk/LayoutTests/fast/parser/document-write-basic.html 2013-02-08 00:24:31 UTC (rev 142200)
@@ -0,0 +1,9 @@
+<html>
+<body>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/parser/document-write-partial-script-external-expected.txt (0 => 142200)
--- trunk/LayoutTests/fast/parser/document-write-partial-script-external-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/parser/document-write-partial-script-external-expected.txt 2013-02-08 00:24:31 UTC (rev 142200)
@@ -0,0 +1,2 @@
+ALERT: PASS: This test passes if this string is alerted
+
Added: trunk/LayoutTests/fast/parser/document-write-partial-script-external.html (0 => 142200)
--- trunk/LayoutTests/fast/parser/document-write-partial-script-external.html (rev 0)
+++ trunk/LayoutTests/fast/parser/document-write-partial-script-external.html 2013-02-08 00:24:31 UTC (rev 142200)
@@ -0,0 +1,8 @@
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+</script>
+<script src=""
+// <iframe _onload_="alert('FAIL: If this string is visible, then this test fails.')" src=""
+alert('PASS: This test passes if this string is alerted');
+</script>
Modified: trunk/Source/WebCore/ChangeLog (142199 => 142200)
--- trunk/Source/WebCore/ChangeLog 2013-02-08 00:18:14 UTC (rev 142199)
+++ trunk/Source/WebCore/ChangeLog 2013-02-08 00:24:31 UTC (rev 142200)
@@ -1,3 +1,23 @@
+2013-02-07 Adam Barth <aba...@webkit.org>
+
+ fast/parser/document-write-noscript.html fails for threaded HTML parser
+ https://bugs.webkit.org/show_bug.cgi?id=109237
+
+ Reviewed by Eric Seidel.
+
+ If there are multiple calls to document.write in an external script, we
+ need to wait for them all to complete before invalidating the
+ speculative tokens. Instead of doing this when we unwind the
+ document.write call stack, we do this when we're about to resume
+ parsing after script execution.
+
+ Test: fast/parser/document-write-basic.html
+
+ * html/parser/HTMLDocumentParser.cpp:
+ (WebCore::HTMLDocumentParser::processParsedChunkFromBackgroundParser):
+ (WebCore::HTMLDocumentParser::insert):
+ (WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution):
+
2013-02-07 Lamarque V. Souza <lamarque.so...@basyskom.com>
Fix build when compiling with css3-text and css3-conditional-rules feature flags enabled.
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (142199 => 142200)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-02-08 00:18:14 UTC (rev 142199)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-02-08 00:24:31 UTC (rev 142200)
@@ -287,6 +287,15 @@
processParsedChunkFromBackgroundParser(chunk);
}
+void HTMLDocumentParser::checkForSpeculationFailure()
+{
+ if (!m_tokenizer)
+ return;
+ // FIXME: If the tokenizer is in the same state as when we started this function,
+ // then we haven't necessarily failed our speculation.
+ didFailSpeculation(m_token.release(), m_tokenizer.release());
+}
+
void HTMLDocumentParser::didFailSpeculation(PassOwnPtr<HTMLToken> token, PassOwnPtr<HTMLTokenizer> tokenizer)
{
m_weakFactory.revokeAll();
@@ -305,7 +314,6 @@
// but we need to ensure it isn't deleted yet.
RefPtr<HTMLDocumentParser> protect(this);
- ASSERT(!m_currentChunk);
m_currentChunk = chunk;
OwnPtr<CompactHTMLTokenStream> tokens = m_currentChunk->tokens.release();
@@ -341,7 +349,8 @@
}
}
- m_currentChunk.clear();
+ checkForSpeculationFailure();
+
InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt());
}
@@ -483,15 +492,6 @@
m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource);
pumpTokenizerIfPossible(ForceSynchronous);
-#if ENABLE(THREADED_HTML_PARSER)
- if (!inPumpSession() && m_haveBackgroundParser) {
- // FIXME: If the tokenizer is in the same state as when we started this function,
- // then we haven't necessarily failed our speculation.
- didFailSpeculation(m_token.release(), m_tokenizer.release());
- return;
- }
-#endif
-
if (isWaitingForScripts()) {
// Check the document.write() output with a separate preload scanner as
// the main scanner can't deal with insertions.
@@ -714,7 +714,9 @@
ASSERT(!isWaitingForScripts());
#if ENABLE(THREADED_HTML_PARSER)
- if (shouldUseThreading()) {
+ if (m_haveBackgroundParser) {
+ checkForSpeculationFailure();
+
while (!m_speculations.isEmpty()) {
processParsedChunkFromBackgroundParser(m_speculations.takeFirst());
if (isWaitingForScripts() || isStopped())
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (142199 => 142200)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-02-08 00:18:14 UTC (rev 142199)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-02-08 00:24:31 UTC (rev 142200)
@@ -129,6 +129,7 @@
#if ENABLE(THREADED_HTML_PARSER)
void startBackgroundParser();
void stopBackgroundParser();
+ void checkForSpeculationFailure();
void didFailSpeculation(PassOwnPtr<HTMLToken>, PassOwnPtr<HTMLTokenizer>);
void processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk>);
#endif