// |jit-test| skip-if: getBuildConfiguration("release_or_beta") // // JS::SafeResolve of a thenable settles the outer promise at the SAME // microtask depth as an ordinary resolve(thenable). Under the updated // thenable-curtailment spec, PerformPromiseResolution runs in ~deferred~ // mode: when it finds a callable "then" it invokes PerformPromiseResolveThenable // synchronously rather than enqueuing a further job, so the deferred resolution // does not add an extra tick relative to normal assimilation.
// Measure at which microtask "tick" the outer reaction fires, by racing it // against a chain of native-promise reactions that bump `tick`. function measure(installResolution) { const {promise} = Promise.withResolvers();
let ticksAtFulfill = -1;
let tick = 0;
promise.then(() => { ticksAtFulfill = tick; });
installResolution(promise);
let pending = Promise.resolve(); for (let i = 0; i < 6; i++) {
pending = pending.then(() => { tick++; });
}
drainJobQueue();
assertEq(ticksAtFulfill >= 0, true, "reaction fired at some tick"); return ticksAtFulfill;
}
// Baseline: a normal resolve(thenable). The resolve function lives on the // capability, so we need the resolvers; reproduce measure() inline to get it. function measureNormal() { const {promise, resolve} = Promise.withResolvers();
let ticksAtFulfill = -1;
let tick = 0;
promise.then(() => { ticksAtFulfill = tick; });
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.