зеркало из https://github.com/mozilla/gecko-dev.git
Bug 568470 - Flush ops from off-the-main-thread HTML5 tree builder into executor immediately when stopping speculating. r=bnewman.
--HG-- extra : rebase_source : 12abdc2cab8f8e96587ef11ba8b62cabb2b2acbb
This commit is contained in:
Родитель
788d95420b
Коммит
2dcb455ba6
|
@ -992,6 +992,13 @@ nsHtml5StreamParser::ContinueAfterScripts(nsHtml5Tokenizer* aTokenizer,
|
||||||
mSpeculations.RemoveElementAt(0);
|
mSpeculations.RemoveElementAt(0);
|
||||||
if (mSpeculations.IsEmpty()) {
|
if (mSpeculations.IsEmpty()) {
|
||||||
// yes, it was still the only speculation. Now stop speculating
|
// yes, it was still the only speculation. Now stop speculating
|
||||||
|
if (mTreeBuilder->IsDiscretionaryFlushSafe()) {
|
||||||
|
// However, before telling the executor to read from stage, flush
|
||||||
|
// any pending ops straight to the executor, because otherwise
|
||||||
|
// they remain unflushed until we get more data from the network.
|
||||||
|
mTreeBuilder->SetOpSink(mExecutor);
|
||||||
|
mTreeBuilder->Flush();
|
||||||
|
}
|
||||||
mTreeBuilder->SetOpSink(mExecutor->GetStage());
|
mTreeBuilder->SetOpSink(mExecutor->GetStage());
|
||||||
mExecutor->StartReadingFromStage();
|
mExecutor->StartReadingFromStage();
|
||||||
mSpeculating = PR_FALSE;
|
mSpeculating = PR_FALSE;
|
||||||
|
|
|
@ -62,6 +62,9 @@ _TEST_FILES = parser_datreader.js \
|
||||||
test_bug566879.html \
|
test_bug566879.html \
|
||||||
test_compatmode.html \
|
test_compatmode.html \
|
||||||
invalidchar.xml \
|
invalidchar.xml \
|
||||||
|
test_bug568470.html \
|
||||||
|
file_bug568470.sjs \
|
||||||
|
file_bug568470-script.sjs \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
function handleRequest(request, response)
|
||||||
|
{
|
||||||
|
response.setHeader("Cache-Control", "no-cache", false);
|
||||||
|
response.setHeader("Content-Type", "text/javascript", false);
|
||||||
|
response.write("var i = 0;");
|
||||||
|
response.bodyOutputStream.flush();
|
||||||
|
response.processAsync();
|
||||||
|
var timer = Components.classes["@mozilla.org/timer;1"]
|
||||||
|
.createInstance(Components.interfaces.nsITimer);
|
||||||
|
timer.initWithCallback(function() {
|
||||||
|
response.finish();
|
||||||
|
}, 500, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
function handleRequest(request, response)
|
||||||
|
{
|
||||||
|
response.setHeader("Cache-Control", "no-cache", false);
|
||||||
|
response.setHeader("Content-Type", "text/html", false);
|
||||||
|
response.write("<script src='file_bug568470-script.sjs'></script>");
|
||||||
|
response.write("<div id='flushable'>");
|
||||||
|
for (var i = 0; i < 2000; i++) {
|
||||||
|
response.write("Lorem ipsum dolor sit amet. ");
|
||||||
|
}
|
||||||
|
response.write("</div>");
|
||||||
|
response.bodyOutputStream.flush();
|
||||||
|
response.processAsync();
|
||||||
|
var timer = Components.classes["@mozilla.org/timer;1"]
|
||||||
|
.createInstance(Components.interfaces.nsITimer);
|
||||||
|
timer.initWithCallback(function() {
|
||||||
|
response.finish();
|
||||||
|
}, 1200, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=568470
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 568470</title>
|
||||||
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=568470">Mozilla Bug 568470</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<pre id="test">
|
||||||
|
<script class="testbody" type="text/javascript">
|
||||||
|
/** Test for Bug 568470 **/
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
// assuming the test runs in less than a year...
|
||||||
|
var time = new Date().getTime() + 1000*60*60*24*365;
|
||||||
|
|
||||||
|
var interval = setInterval(function() {
|
||||||
|
var iframe = document.getElementsByTagName("iframe")[0];
|
||||||
|
if (iframe) {
|
||||||
|
var doc = iframe.contentDocument;
|
||||||
|
if (doc) {
|
||||||
|
if (doc.getElementById("flushable")) {
|
||||||
|
time = new Date();
|
||||||
|
clearInterval(interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
function finish() {
|
||||||
|
clearInterval(interval);
|
||||||
|
var elapsed = new Date().getTime() - time;
|
||||||
|
ok(elapsed > 400,
|
||||||
|
"Content flush time and parse end time not enough apart.");
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
<iframe onload="finish();" src="file_bug568470.sjs"></iframe>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче