mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1062323 - Chained promises should resolve asynchronously. r=bz
This commit is contained in:
parent
e7b332bdfb
commit
1a14ca5478
@ -203,13 +203,13 @@ WrapperPromiseCallback::Call(JSContext* aCx,
|
||||
|
||||
ErrorResult rv;
|
||||
|
||||
// If invoking callback threw an exception, run resolver's reject with the
|
||||
// thrown exception as argument and the synchronous flag set.
|
||||
// PromiseReactionTask step 6
|
||||
JS::Rooted<JS::Value> retValue(aCx);
|
||||
mCallback->Call(value, &retValue, rv, CallbackObject::eRethrowExceptions);
|
||||
|
||||
rv.WouldReportJSException();
|
||||
|
||||
// PromiseReactionTask step 7
|
||||
if (rv.Failed() && rv.IsJSException()) {
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
rv.StealJSException(aCx, &value);
|
||||
@ -219,7 +219,7 @@ WrapperPromiseCallback::Call(JSContext* aCx,
|
||||
return;
|
||||
}
|
||||
|
||||
mNextPromise->RejectInternal(aCx, value, Promise::SyncTask);
|
||||
mNextPromise->RejectInternal(aCx, value);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -284,14 +284,13 @@ WrapperPromiseCallback::Call(JSContext* aCx,
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, run resolver's resolve with value and the synchronous flag
|
||||
// set.
|
||||
// Otherwise, run resolver's resolve with value.
|
||||
if (!JS_WrapValue(aCx, &retValue)) {
|
||||
NS_WARNING("Failed to wrap value into the right compartment.");
|
||||
return;
|
||||
}
|
||||
|
||||
mNextPromise->ResolveInternal(aCx, retValue, Promise::SyncTask);
|
||||
mNextPromise->ResolveInternal(aCx, retValue);
|
||||
}
|
||||
|
||||
// NativePromiseCallback
|
||||
|
@ -674,6 +674,45 @@ function promiseTestAsyncThenableResolution()
|
||||
});
|
||||
}
|
||||
|
||||
// Bug 1062323
|
||||
function promiseWrapperAsyncResolution()
|
||||
{
|
||||
var p = new Promise(function(resolve, reject){
|
||||
resolve();
|
||||
});
|
||||
|
||||
var results = [];
|
||||
var q = p.then(function () {
|
||||
results.push("1-1");
|
||||
}).then(function () {
|
||||
results.push("1-2");
|
||||
}).then(function () {
|
||||
results.push("1-3");
|
||||
});
|
||||
|
||||
var r = p.then(function () {
|
||||
results.push("2-1");
|
||||
}).then(function () {
|
||||
results.push("2-2");
|
||||
}).then(function () {
|
||||
results.push("2-3");
|
||||
});
|
||||
|
||||
Promise.all([q, r]).then(function() {
|
||||
var match = results[0] == "1-1" &&
|
||||
results[1] == "2-1" &&
|
||||
results[2] == "1-2" &&
|
||||
results[3] == "2-2" &&
|
||||
results[4] == "1-3" &&
|
||||
results[5] == "2-3";
|
||||
ok(match, "Chained promises should resolve asynchronously.");
|
||||
runTest();
|
||||
}, function() {
|
||||
ok(false, "promiseWrapperAsyncResolution: One of the promises failed.");
|
||||
runTest();
|
||||
});
|
||||
}
|
||||
|
||||
var tests = [ promiseResolve, promiseReject,
|
||||
promiseException, promiseGC, promiseAsync,
|
||||
promiseDoubleThen, promiseThenException,
|
||||
@ -706,6 +745,7 @@ var tests = [ promiseResolve, promiseReject,
|
||||
promiseResolvePromise,
|
||||
promiseResolveThenableCleanStack,
|
||||
promiseTestAsyncThenableResolution,
|
||||
promiseWrapperAsyncResolution,
|
||||
];
|
||||
|
||||
function runTest() {
|
||||
|
Loading…
Reference in New Issue
Block a user