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:
Brian Hackett 2019-09-16 20:17:17 +00:00
Родитель 18ac180309
Коммит 0a791285af
3 изменённых файлов: 14 добавлений и 5 удалений

Просмотреть файл

@ -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() {},
};