Commit bc8826ef authored by rafaelw@chromium.org's avatar rafaelw@chromium.org

Only Microtask::performCheckpoint() if recursionLevel is 0

This maintains the invariant that microtask work (e.g. Mutation Observer callbacks) always occur on an empty page script stack.

Previously, it was possible for a microtask to fire before the outer script had exited on document.write('<script>') or showModalDialog, etc..

R=adamk@chromium.org, adamk
BUG=352181

Review URL: https://codereview.chromium.org/184043002

git-svn-id: svn://svn.chromium.org/blink/trunk@169770 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent cabd8000
<!DOCTYPE html>
<head>
</head>
<body>
<div id="result">RESULT</div>
<script>
var resultDiv = document.getElementById('result');
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var count = 0;
var observer = new MutationObserver(function(r) {
count += r.length;
});
var div = document.createElement('div');
observer.observe(div, { attributes: true });
function mutate() {
div.setAttribute('count', count);
}
var counts = [];
function check() {
counts.push(count);
}
function finish() {
setTimeout(function() {
check();
var result = counts[0] == 0 &&
counts[1] == 0 &&
counts[2] == 0 &&
counts[3] == 1 ? 'PASSED' : 'FAILED';
document.documentElement.appendChild(document.createElement('body'));
document.body.innerHTML = result;
if (window.testRunner) {
testRunner.notifyDone();
}
}, 0);
}
finish();
</script>
<iframe onload="mutate(); check(); document.write('<script>check();</script>'); check(); finish();">
</body>
......@@ -48,7 +48,7 @@ void Microtask::performCheckpoint()
{
V8PerIsolateData* isolateData = V8PerIsolateData::current();
ASSERT(isolateData);
if (isolateData->performingMicrotaskCheckpoint())
if (isolateData->recursionLevel() || isolateData->performingMicrotaskCheckpoint())
return;
isolateData->setPerformingMicrotaskCheckpoint(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment