зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1140472 - Set an async stack when invoking promise handlers. r=bz
This commit is contained in:
Родитель
0e3f0518f1
Коммит
e5306bdeb5
|
@ -84,9 +84,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1107592
|
|||
"doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:79:6\n")),
|
||||
t.testPromiseWithDOMExceptionThrowingThenFunction().then(
|
||||
ensurePromiseFail.bind(null, 8),
|
||||
checkExn.bind(null, 0, "NetworkError",
|
||||
checkExn.bind(null, 85, "NetworkError",
|
||||
"We are a third DOMException",
|
||||
DOMException.NETWORK_ERR, "", 8, "")),
|
||||
DOMException.NETWORK_ERR, ourFile, 8,
|
||||
"Async*doTest@http://mochi.test:8888/tests/dom/bindings/test/test_promise_rejections_from_jsimplemented.html:85:6\n")),
|
||||
t.testPromiseWithDOMExceptionThrowingThenable().then(
|
||||
ensurePromiseFail.bind(null, 9),
|
||||
checkExn.bind(null, 0, "TypeMismatchError",
|
||||
|
|
|
@ -77,7 +77,20 @@ protected:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
mCallback->Call(cx, value);
|
||||
JS::Rooted<JSObject*> asyncStack(cx, mPromise->mAllocationStack);
|
||||
JS::Rooted<JSString*> asyncCause(cx, JS_NewStringCopyZ(cx, "Promise"));
|
||||
if (!asyncCause) {
|
||||
JS_ClearPendingException(cx);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
{
|
||||
Maybe<JS::AutoSetAsyncStackForNewCalls> sas;
|
||||
if (asyncStack) {
|
||||
sas.emplace(cx, asyncStack, asyncCause);
|
||||
}
|
||||
mCallback->Call(cx, value);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ class Promise : public nsISupports,
|
|||
public SupportsWeakPtr<Promise>
|
||||
{
|
||||
friend class NativePromiseCallback;
|
||||
friend class PromiseCallbackTask;
|
||||
friend class PromiseResolverTask;
|
||||
friend class PromiseTask;
|
||||
friend class PromiseReportRejectFeature;
|
||||
|
|
|
@ -107,7 +107,7 @@ Assert.AssertionError = function(options) {
|
|||
// The part of the stack that comes from this module is not interesting.
|
||||
let stack = Components.stack;
|
||||
do {
|
||||
stack = stack.caller;
|
||||
stack = stack.asyncCaller || stack.caller;
|
||||
} while(stack.filename && stack.filename.contains("Assert.jsm"))
|
||||
this.stack = stack;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче