зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1575306 - Suppress reporting of uncaught testing sentinel, r=bzbarsky.
Differential Revision: https://phabricator.services.mozilla.com/D45964 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
18ac180309
Коммит
0a791285af
|
@ -32,13 +32,14 @@ enum PromiseDebuggingState { "pending", "fulfilled", "rejected" };
|
|||
callback interface UncaughtRejectionObserver {
|
||||
/**
|
||||
* A Promise has been left in `rejected` state and is the
|
||||
* last in its chain.
|
||||
* last in its chain. If this callback returns true, the rejection
|
||||
* will not be reported.
|
||||
*
|
||||
* @param p A currently uncaught Promise. If `p` is is eventually
|
||||
* caught, i.e. if its `then` callback is called, `onConsumed` will
|
||||
* be called.
|
||||
*/
|
||||
void onLeftUncaught(object p);
|
||||
boolean onLeftUncaught(object p);
|
||||
|
||||
/**
|
||||
* A Promise previously left uncaught is not the last in its
|
||||
|
|
|
@ -265,14 +265,20 @@ void PromiseDebugging::FlushUncaughtRejectionsInternal() {
|
|||
continue;
|
||||
}
|
||||
|
||||
bool suppressReporting = false;
|
||||
for (size_t j = 0; j < observers.Length(); ++j) {
|
||||
RefPtr<UncaughtRejectionObserver> obs =
|
||||
static_cast<UncaughtRejectionObserver*>(observers[j].get());
|
||||
|
||||
obs->OnLeftUncaught(promise, IgnoreErrors());
|
||||
if (obs->OnLeftUncaught(promise, IgnoreErrors())) {
|
||||
suppressReporting = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!suppressReporting) {
|
||||
JSAutoRealm ar(cx, promise);
|
||||
Promise::ReportRejectedPromise(cx, promise);
|
||||
}
|
||||
JSAutoRealm ar(cx, promise);
|
||||
Promise::ReportRejectedPromise(cx, promise);
|
||||
}
|
||||
storage->mUncaughtRejections.clear();
|
||||
|
||||
|
|
|
@ -102,7 +102,9 @@ var PromiseTestUtils = {
|
|||
this._ensureDOMPromiseRejectionsProcessedReason
|
||||
) {
|
||||
observed = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
onConsumed() {},
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче