mirror of
https://github.com/servo/servo.git
synced 2025-10-12 14:30:25 +01:00
Fix timeout vs. dom manipulation queue race conditions
This commit is contained in:
parent
5f55cd5d71
commit
7684afb8b1
3 changed files with 35 additions and 26 deletions
|
@ -27,11 +27,21 @@ async_test(function(t) {
|
|||
};
|
||||
|
||||
var p = Promise.reject(e);
|
||||
setTimeout(function() {
|
||||
setTimeout(t.step_func(function() {
|
||||
queueTask(function() {
|
||||
queueTask(t.step_func(function() {
|
||||
// This will cause onrejectionhandled
|
||||
p.catch(function() {});
|
||||
}), 0);
|
||||
}, 0);
|
||||
}));
|
||||
});
|
||||
}, 'Throwing inside an unhandledrejection handler invokes the error handler.');
|
||||
|
||||
// This function queues a task in "DOM manipulation task source"
|
||||
function queueTask(f) {
|
||||
var d = document.createElement("details");
|
||||
d.ontoggle = function() {
|
||||
f();
|
||||
};
|
||||
|
||||
d.setAttribute("open", "");
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -831,30 +831,29 @@ if ('document' in self) {
|
|||
|
||||
var p = Promise.reject();
|
||||
|
||||
setTimeout(function() {
|
||||
queueTask(function() {
|
||||
sequenceOfEvents.push('task before catch');
|
||||
checkSequence();
|
||||
});
|
||||
|
||||
p.catch(function() {
|
||||
sequenceOfEvents.push('catch');
|
||||
checkSequence();
|
||||
});
|
||||
|
||||
queueTask(function() {
|
||||
sequenceOfEvents.push('task after catch');
|
||||
checkSequence();
|
||||
});
|
||||
|
||||
sequenceOfEvents.push('after catch');
|
||||
checkSequence();
|
||||
}, 10);
|
||||
|
||||
function unhandled(ev) {
|
||||
if (ev.promise === p) {
|
||||
sequenceOfEvents.push('unhandled');
|
||||
checkSequence();
|
||||
setTimeout(function() {
|
||||
queueTask(function() {
|
||||
sequenceOfEvents.push('task before catch');
|
||||
checkSequence();
|
||||
});
|
||||
|
||||
p.catch(function() {
|
||||
sequenceOfEvents.push('catch');
|
||||
checkSequence();
|
||||
});
|
||||
|
||||
queueTask(function() {
|
||||
sequenceOfEvents.push('task after catch');
|
||||
checkSequence();
|
||||
});
|
||||
|
||||
sequenceOfEvents.push('after catch');
|
||||
checkSequence();
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue