mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #25698 - pshaughn:rejectiontests, r=jdm
Fix timeout vs. task-queue race conditions in promise rejection tests <!-- Please describe your changes on the following line: --> These two tests were assuming that timeouts and promise rejection events would have a temporal relationship not actually guaranteed by spec, leading to test timeouts if the DOM manipulation task queue was running slower than anticipated. fix #22207, fix #22295 Of course, the upstream WPT results need looking at to be sure this hasn't done something weird to another browser.
This commit is contained in:
commit
5bcd0d8dd0
3 changed files with 35 additions and 26 deletions
|
@ -698932,7 +698932,7 @@
|
|||
"testharness"
|
||||
],
|
||||
"html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-onerror.html": [
|
||||
"b6f6d63e0aa9660909c93e7366f80f4f36c97ecf",
|
||||
"b6c02d27c9ef67418210e808eb92256606c273c7",
|
||||
"testharness"
|
||||
],
|
||||
"html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events.dedicatedworker.html": [
|
||||
|
@ -698956,7 +698956,7 @@
|
|||
"support"
|
||||
],
|
||||
"html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/support/promise-rejection-events.js": [
|
||||
"f371bc1da900a596b6e49dbe86b22a7c20ae2cc2",
|
||||
"036e1784dbb79e07cd533256cd391583191f4aa8",
|
||||
"support"
|
||||
],
|
||||
"html/webappapis/scripting/processing-model-2/window-onerror-parse-error.html": [
|
||||
|
|
|
@ -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