summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
authorAndreu Botella <abb@randomunok.com>2021-12-11 00:30:46 +0100
committerGitHub <noreply@github.com>2021-12-10 18:30:46 -0500
commita3aa2c184c2543a0cb8ded727c01be84cf7b4f96 (patch)
tree19f6e4a52378d80e345cf784b6781f0c7757c0c6 /runtime/js
parentcbfc8dd59d79fa6e8c5a59ca97508ea4285ff155 (diff)
fix(test): Make the op sanitizer delay macrotask into a queue (#12966)
Fixes #12945.
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/40_testing.js18
1 files changed, 6 insertions, 12 deletions
diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js
index e8b07d494..90da6ddb0 100644
--- a/runtime/js/40_testing.js
+++ b/runtime/js/40_testing.js
@@ -12,6 +12,7 @@
AggregateError,
ArrayPrototypeFilter,
ArrayPrototypePush,
+ ArrayPrototypeShift,
ArrayPrototypeSome,
DateNow,
Error,
@@ -30,7 +31,7 @@
} = window.__bootstrap.primordials;
let testStepsEnabled = false;
- let opSanitizerDelayResolve = null;
+ const opSanitizerDelayResolveQueue = [];
// Even if every resource is closed by the end of a test, there can be a delay
// until the pending ops have all finished. This function returns a promise
@@ -42,23 +43,16 @@
// before that, though, in order to give time for worker message ops to finish
// (since timeouts of 0 don't queue tasks in the timer queue immediately).
function opSanitizerDelay() {
- return new Promise((resolve, reject) => {
+ return new Promise((resolve) => {
setTimeout(() => {
- if (opSanitizerDelayResolve !== null) {
- reject(new Error("There is an op sanitizer delay already."));
- } else {
- opSanitizerDelayResolve = resolve;
- }
+ ArrayPrototypePush(opSanitizerDelayResolveQueue, resolve);
}, 0);
});
}
function handleOpSanitizerDelayMacrotask() {
- if (opSanitizerDelayResolve !== null) {
- opSanitizerDelayResolve();
- opSanitizerDelayResolve = null;
- }
- return true;
+ ArrayPrototypeShift(opSanitizerDelayResolveQueue)?.();
+ return opSanitizerDelayResolveQueue.length === 0;
}
// Wrap test function in additional assertion that makes sure