mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1923864 - Crash differently if not JS_IsThrowingOutOfMemory a=RyanVM
Original Revision: https://phabricator.services.mozilla.com/D226997 Differential Revision: https://phabricator.services.mozilla.com/D227412
This commit is contained in:
parent
f97b09812f
commit
b595303920
@ -108,8 +108,13 @@ already_AddRefed<Promise> Promise::CreateInfallible(
|
||||
RefPtr<Promise> p = new Promise(aGlobal);
|
||||
IgnoredErrorResult rv;
|
||||
p->CreateWrapper(rv, aPropagateUserInteraction);
|
||||
if (rv.Failed() && rv.ErrorCodeIs(NS_ERROR_OUT_OF_MEMORY)) {
|
||||
MOZ_CRASH("Out of memory");
|
||||
if (rv.Failed()) {
|
||||
if (rv.ErrorCodeIs(NS_ERROR_OUT_OF_MEMORY)) {
|
||||
NS_ABORT_OOM(0); // (0 meaning unknown size)
|
||||
}
|
||||
if (rv.ErrorCodeIs(NS_ERROR_NOT_INITIALIZED)) {
|
||||
MOZ_CRASH("Failed to create promise wrapper for unknown non-OOM reason");
|
||||
}
|
||||
}
|
||||
|
||||
// We may have failed to init the wrapper here, because nsIGlobalObject had
|
||||
@ -292,8 +297,10 @@ void Promise::CreateWrapper(
|
||||
JSContext* cx = jsapi.cx();
|
||||
mPromiseObj = JS::NewPromiseObject(cx, nullptr);
|
||||
if (!mPromiseObj) {
|
||||
nsresult error = JS_IsThrowingOutOfMemory(cx) ? NS_ERROR_OUT_OF_MEMORY
|
||||
: NS_ERROR_NOT_INITIALIZED;
|
||||
JS_ClearPendingException(cx);
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
aRv.Throw(error);
|
||||
return;
|
||||
}
|
||||
if (aPropagateUserInteraction == ePropagateUserInteraction) {
|
||||
|
@ -409,6 +409,10 @@ class Promise : public SupportsWeakPtr {
|
||||
// Pass ePropagateUserInteraction for aPropagateUserInteraction if you want
|
||||
// the promise resolve handler to be called as if we were handling user
|
||||
// input events in case we are currently handling user input events.
|
||||
// The error code can be:
|
||||
// * NS_ERROR_UNEXPECTED when AutoJSAPI.Init fails
|
||||
// * NS_ERROR_OUT_OF_MEMORY when NewPromiseObject throws OOM
|
||||
// * NS_ERROR_NOT_INITIALIZED when NewPromiseObject fails without OOM
|
||||
void CreateWrapper(ErrorResult& aRv,
|
||||
PropagateUserInteraction aPropagateUserInteraction =
|
||||
eDontPropagateUserInteraction);
|
||||
|
Loading…
Reference in New Issue
Block a user