mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 08:48:39 +09:00
Issue #2435 - Implement notifying of rejected promises
Based-on: m-c 1362272
This commit is contained in:
parent
65d72c5682
commit
9126a4836f
4 changed files with 165 additions and 2 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include "mozilla/mozalloc.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/SegmentedVector.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
|
|
@ -474,6 +475,47 @@ private:
|
|||
|
||||
uint32_t mMicroTaskRecursionDepth;
|
||||
|
||||
// This implements about-to-be-notified rejected promises list in the spec.
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#about-to-be-notified-rejected-promises-list
|
||||
typedef nsTArray<RefPtr<dom::Promise>> PromiseArray;
|
||||
PromiseArray mAboutToBeNotifiedRejectedPromises;
|
||||
|
||||
// This is for the "outstanding rejected promises weak set" in the spec,
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#outstanding-rejected-promises-weak-set
|
||||
// We use different data structure and opposite logic here to achieve the same
|
||||
// effect. Basically this is used for tracking the rejected promise that does
|
||||
// NOT need firing a rejectionhandled event. We will check the table to see if
|
||||
// firing rejectionhandled event is required when a rejected promise is being
|
||||
// handled.
|
||||
//
|
||||
// The rejected promise will be stored in the table if
|
||||
// - it is unhandled, and
|
||||
// - The unhandledrejection is not yet fired.
|
||||
//
|
||||
// And be removed when
|
||||
// - it is handled, or
|
||||
// - A unhandledrejection is fired and it isn't being handled in event
|
||||
// handler.
|
||||
typedef nsRefPtrHashtable<nsUint64HashKey, dom::Promise> PromiseHashtable;
|
||||
PromiseHashtable mPendingUnhandledRejections;
|
||||
|
||||
class NotifyUnhandledRejections final : public CancelableRunnable {
|
||||
public:
|
||||
NotifyUnhandledRejections(CycleCollectedJSContext* aCx,
|
||||
PromiseArray&& aPromises)
|
||||
: CancelableRunnable(),
|
||||
mCx(aCx),
|
||||
mUnhandledRejections(std::move(aPromises)) {}
|
||||
|
||||
NS_IMETHOD Run() final;
|
||||
|
||||
nsresult Cancel() final;
|
||||
|
||||
private:
|
||||
CycleCollectedJSContext* mCx;
|
||||
PromiseArray mUnhandledRejections;
|
||||
};
|
||||
|
||||
OOMState mOutOfMemoryState;
|
||||
OOMState mLargeAllocationFailureState;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue