1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PromiseRejectionEvent_h
6 #define PromiseRejectionEvent_h
8 #include "bindings/core/v8/DOMWrapperWorld.h"
9 #include "bindings/core/v8/ScopedPersistent.h"
10 #include "bindings/core/v8/ScriptPromise.h"
11 #include "bindings/core/v8/ScriptState.h"
12 #include "bindings/core/v8/ScriptValue.h"
13 #include "core/CoreExport.h"
14 #include "core/events/Event.h"
15 #include "core/events/PromiseRejectionEventInit.h"
19 class CORE_EXPORT PromiseRejectionEvent final
: public Event
{
20 DEFINE_WRAPPERTYPEINFO();
22 static PassRefPtrWillBeRawPtr
<PromiseRejectionEvent
> create()
24 return adoptRefWillBeNoop(new PromiseRejectionEvent
);
26 static PassRefPtrWillBeRawPtr
<PromiseRejectionEvent
> create(ScriptState
* state
, const AtomicString
& type
, const PromiseRejectionEventInit
& initializer
)
28 return adoptRefWillBeNoop(new PromiseRejectionEvent(state
, type
, initializer
));
31 ScriptValue
reason(ScriptState
*) const;
32 ScriptPromise
promise(ScriptState
*) const;
34 void setWrapperReference(v8::Isolate
*, const v8::Persistent
<v8::Object
>&);
36 const AtomicString
& interfaceName() const override
;
38 // PromiseRejectionEvents are similar to ErrorEvents in that they can't be
39 // observed across different worlds.
40 bool canBeDispatchedInWorld(const DOMWrapperWorld
&) const override
;
42 DECLARE_VIRTUAL_TRACE();
45 PromiseRejectionEvent();
46 PromiseRejectionEvent(ScriptState
*, const AtomicString
&, const PromiseRejectionEventInit
&);
47 ~PromiseRejectionEvent() override
;
49 static void didCollectPromise(const v8::WeakCallbackInfo
<PromiseRejectionEvent
>&);
50 static void didCollectReason(const v8::WeakCallbackInfo
<PromiseRejectionEvent
>&);
52 RefPtr
<ScriptState
> m_scriptState
;
53 ScopedPersistent
<v8::Value
> m_promise
;
54 ScopedPersistent
<v8::Value
> m_reason
;
59 #endif // PromiseRejectionEvent_h