зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1534392) for failing in ecma262-issue-1461.js CLOSED TREE
Backed out changeset 4c52efb1430f (bug 1534392) Backed out changeset 47e570e51385 (bug 1534392)
This commit is contained in:
Родитель
e163a5bcea
Коммит
0e4b64877d
|
@ -3549,8 +3549,8 @@ MOZ_MUST_USE bool js::AsyncFunctionReturned(
|
||||||
|
|
||||||
// https://tc39.github.io/ecma262/#await
|
// https://tc39.github.io/ecma262/#await
|
||||||
//
|
//
|
||||||
// Helper function that performs 6.2.3.1 Await(promise) steps 2 and 9.
|
// Helper function that performs 6.2.3.1 Await(promise) steps 2-3 and 10, or
|
||||||
// The same steps are also used in a few other places in the spec.
|
// similar.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static MOZ_MUST_USE bool InternalAwait(JSContext* cx, HandleValue value,
|
static MOZ_MUST_USE bool InternalAwait(JSContext* cx, HandleValue value,
|
||||||
HandleObject resultPromise,
|
HandleObject resultPromise,
|
||||||
|
@ -3559,7 +3559,10 @@ static MOZ_MUST_USE bool InternalAwait(JSContext* cx, HandleValue value,
|
||||||
MOZ_ASSERT(onFulfilled.isInt32());
|
MOZ_ASSERT(onFulfilled.isInt32());
|
||||||
MOZ_ASSERT(onRejected.isInt32());
|
MOZ_ASSERT(onRejected.isInt32());
|
||||||
|
|
||||||
// Step 2: Let promise be ? PromiseResolve(%Promise%, « value »).
|
// The proposal <https://github.com/tc39/ecma262/pull/1250>
|
||||||
|
// replaces steps 2-3 with the following updated step:
|
||||||
|
// Step 2: Let promise be ? PromiseResolve(« value »).
|
||||||
|
// Step 3 is deleted.
|
||||||
RootedObject promise(cx, PromiseObject::unforgeableResolve(cx, value));
|
RootedObject promise(cx, PromiseObject::unforgeableResolve(cx, value));
|
||||||
if (!promise) {
|
if (!promise) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -3574,9 +3577,7 @@ static MOZ_MUST_USE bool InternalAwait(JSContext* cx, HandleValue value,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Steps 3-8 of the spec create onFulfilled and onRejected functions.
|
// Steps 4-9 of the spec create onFulfilled and onRejected functions.
|
||||||
|
|
||||||
// Step 9: Perform ! PerformPromiseThen(promise, onFulfilled, onRejected).
|
|
||||||
Rooted<PromiseCapability> resultCapability(cx);
|
Rooted<PromiseCapability> resultCapability(cx);
|
||||||
resultCapability.promise().set(resultPromise);
|
resultCapability.promise().set(resultPromise);
|
||||||
Rooted<PromiseReactionRecord*> reaction(
|
Rooted<PromiseReactionRecord*> reaction(
|
||||||
|
@ -3586,6 +3587,8 @@ static MOZ_MUST_USE bool InternalAwait(JSContext* cx, HandleValue value,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
extraStep(reaction);
|
extraStep(reaction);
|
||||||
|
|
||||||
|
// Step 10: Perform ! PerformPromiseThen(promise, onFulfilled, onRejected).
|
||||||
return PerformPromiseThenWithReaction(cx, unwrappedPromise, reaction);
|
return PerformPromiseThenWithReaction(cx, unwrappedPromise, reaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3798,9 +3801,6 @@ bool js::AsyncFromSyncIteratorMethod(JSContext* cx, CallArgs& args,
|
||||||
return AbruptRejectPromise(cx, args, resultPromise, nullptr);
|
return AbruptRejectPromise(cx, args, resultPromise, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step numbers below include the changes in
|
|
||||||
// <https://github.com/tc39/ecma262/pull/1470>, which inserted a new step 6.
|
|
||||||
//
|
|
||||||
// Steps 7-9 (reordered).
|
// Steps 7-9 (reordered).
|
||||||
// Step 7: Let steps be the algorithm steps defined in Async-from-Sync
|
// Step 7: Let steps be the algorithm steps defined in Async-from-Sync
|
||||||
// Iterator Value Unwrap Functions.
|
// Iterator Value Unwrap Functions.
|
||||||
|
@ -3812,17 +3812,17 @@ bool js::AsyncFromSyncIteratorMethod(JSContext* cx, CallArgs& args,
|
||||||
: PromiseHandlerAsyncFromSyncIteratorValueUnwrapNotDone));
|
: PromiseHandlerAsyncFromSyncIteratorValueUnwrapNotDone));
|
||||||
RootedValue onRejected(cx, Int32Value(PromiseHandlerThrower));
|
RootedValue onRejected(cx, Int32Value(PromiseHandlerThrower));
|
||||||
|
|
||||||
// Steps 5 and 10 are identical to some steps in Await; we have a utility
|
// These steps are identical to some steps in Await; we have a utility
|
||||||
// function InternalAwait() that implements the idiom.
|
// function InternalAwait() that implements the idiom.
|
||||||
//
|
//
|
||||||
// Step 5: Let valueWrapper be PromiseResolve(%Promise%, « value »).
|
// Steps 5-6, as amended by <https://github.com/tc39/ecma262/pull/1250>:
|
||||||
// Step 6: IfAbruptRejectPromise(valueWrapper, promiseCapability).
|
// Let valueWrapper be ? PromiseResolve(« value »).
|
||||||
// Step 10: Perform ! PerformPromiseThen(valueWrapper, onFulfilled,
|
// Step 10: Perform ! PerformPromiseThen(valueWrapper, onFulfilled,
|
||||||
// undefined, promiseCapability).
|
// undefined, promiseCapability).
|
||||||
auto extra = [](Handle<PromiseReactionRecord*> reaction) {};
|
auto extra = [](Handle<PromiseReactionRecord*> reaction) {};
|
||||||
if (!InternalAwait(cx, value, resultPromise, onFulfilled, onRejected,
|
if (!InternalAwait(cx, value, resultPromise, onFulfilled, onRejected,
|
||||||
extra)) {
|
extra)) {
|
||||||
return AbruptRejectPromise(cx, args, resultPromise, nullptr);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 11: Return promiseCapability.[[Promise]].
|
// Step 11: Return promiseCapability.[[Promise]].
|
||||||
|
@ -3994,18 +3994,18 @@ static MOZ_MUST_USE bool AsyncGeneratorResumeNext(
|
||||||
unwrappedGenerator->setAwaitingReturn();
|
unwrappedGenerator->setAwaitingReturn();
|
||||||
|
|
||||||
// (reordered)
|
// (reordered)
|
||||||
// Step 10.b.i.3: Let stepsFulfilled be the algorithm steps defined in
|
// Step 10.b.i.4: Let stepsFulfilled be the algorithm steps defined in
|
||||||
// AsyncGeneratorResumeNext Return Processor Fulfilled
|
// AsyncGeneratorResumeNext Return Processor Fulfilled
|
||||||
// Functions.
|
// Functions.
|
||||||
// Step 10.b.i.4: Let onFulfilled be CreateBuiltinFunction(
|
// Step 10.b.i.5: Let onFulfilled be CreateBuiltinFunction(
|
||||||
// stepsFulfilled, « [[Generator]] »).
|
// stepsFulfilled, « [[Generator]] »).
|
||||||
// Step 10.b.i.5: Set onFulfilled.[[Generator]] to generator.
|
// Step 10.b.i.6: Set onFulfilled.[[Generator]] to generator.
|
||||||
// Step 10.b.i.6: Let stepsRejected be the algorithm steps defined in
|
// Step 10.b.i.7: Let stepsRejected be the algorithm steps defined in
|
||||||
// AsyncGeneratorResumeNext Return Processor Rejected
|
// AsyncGeneratorResumeNext Return Processor Rejected
|
||||||
// Functions.
|
// Functions.
|
||||||
// Step 10.b.i.7: Let onRejected be CreateBuiltinFunction(
|
// Step 10.b.i.8: Let onRejected be CreateBuiltinFunction(
|
||||||
// stepsRejected, « [[Generator]] »).
|
// stepsRejected, « [[Generator]] »).
|
||||||
// Step 10.b.i.8: Set onRejected.[[Generator]] to generator.
|
// Step 10.b.i.9: Set onRejected.[[Generator]] to generator.
|
||||||
static constexpr int32_t ResumeNextReturnFulfilled =
|
static constexpr int32_t ResumeNextReturnFulfilled =
|
||||||
PromiseHandlerAsyncGeneratorResumeNextReturnFulfilled;
|
PromiseHandlerAsyncGeneratorResumeNextReturnFulfilled;
|
||||||
static constexpr int32_t ResumeNextReturnRejected =
|
static constexpr int32_t ResumeNextReturnRejected =
|
||||||
|
@ -4016,11 +4016,12 @@ static MOZ_MUST_USE bool AsyncGeneratorResumeNext(
|
||||||
// These steps are nearly identical to some steps in Await;
|
// These steps are nearly identical to some steps in Await;
|
||||||
// InternalAwait() implements the idiom.
|
// InternalAwait() implements the idiom.
|
||||||
//
|
//
|
||||||
// Step 10.b.i.2: Let promise be ? PromiseResolve(%Promise%,
|
// Steps 10.b.i.2-3, as amended by
|
||||||
// « _completion_.[[Value]] »).
|
// <https://github.com/tc39/ecma262/pull/1250>:
|
||||||
// Step 10.b.i.9: Perform ! PerformPromiseThen(promise, onFulfilled,
|
// Let promise be ? PromiseResolve(« _completion_.[[Value]] »).
|
||||||
// onRejected).
|
// Step 10.b.i.10: Perform ! PerformPromiseThen(promise, onFulfilled,
|
||||||
// Step 10.b.i.10: Return undefined.
|
// onRejected).
|
||||||
|
// Step 10.b.i.11: Return undefined.
|
||||||
auto extra = [&](Handle<PromiseReactionRecord*> reaction) {
|
auto extra = [&](Handle<PromiseReactionRecord*> reaction) {
|
||||||
reaction->setIsAsyncGenerator(unwrappedGenerator);
|
reaction->setIsAsyncGenerator(unwrappedGenerator);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
// <https://github.com/tc39/ecma262/pull/1470> changes a detail of
|
|
||||||
// error-handling in %AsyncFromSyncIteratorPrototype% methods. This test is
|
|
||||||
// based on a comment in the thread where the issue was first reported,
|
|
||||||
// <https://github.com/tc39/ecma262/issues/1461#issuecomment-468602852>
|
|
||||||
|
|
||||||
let log = [];
|
|
||||||
|
|
||||||
{
|
|
||||||
async function f() {
|
|
||||||
var p = Promise.resolve(0);
|
|
||||||
Object.defineProperty(p, "constructor", {get() { throw "hi" }});
|
|
||||||
for await (var x of [p]);
|
|
||||||
}
|
|
||||||
Promise.resolve(0)
|
|
||||||
.then(() => log.push("tick 1"))
|
|
||||||
.then(() => log.push("tick 2"))
|
|
||||||
.then(() => log.push("tick 3"));
|
|
||||||
f().catch(exc => log.push(exc));
|
|
||||||
}
|
|
||||||
|
|
||||||
drainJobQueue();
|
|
||||||
assertEq(log.join(), "tick 1,tick 2,hi,tick 3");
|
|
||||||
|
|
||||||
if (typeof reportCompare === 'function')
|
|
||||||
reportCompare(0, 0);
|
|
Загрузка…
Ссылка в новой задаче