Index: Source/core/events/PromiseRejectionEvent.cpp |
diff --git a/Source/core/events/PromiseRejectionEvent.cpp b/Source/core/events/PromiseRejectionEvent.cpp |
index 17bb08b177e75014bdce963d50a2217400728d25..2a4eb14da3e3e3f7db1e1889e116c6543a59e2ba 100644 |
--- a/Source/core/events/PromiseRejectionEvent.cpp |
+++ b/Source/core/events/PromiseRejectionEvent.cpp |
@@ -14,16 +14,32 @@ PromiseRejectionEvent::PromiseRejectionEvent() |
PromiseRejectionEvent::PromiseRejectionEvent(const AtomicString& type, const PromiseRejectionEventInit& initializer) |
: Event(type, initializer) |
- , m_reason(initializer.reason()) |
{ |
- if (initializer.hasPromise()) |
- m_promise = initializer.promise(); |
+ if (initializer.hasPromise()) { |
+ m_promise.set(initializer.promise().isolate(), initializer.promise().v8Value()); |
+ m_promise.setWeak(this, &PromiseRejectionEvent::didCollectPromise); |
+ } |
+ if (initializer.hasReason()) { |
+ m_reason.set(initializer.reason().isolate(), initializer.reason().v8Value()); |
+ m_reason.setWeak(this, &PromiseRejectionEvent::didCollectReason); |
+ } |
} |
PromiseRejectionEvent::~PromiseRejectionEvent() |
{ |
} |
+ScriptPromise PromiseRejectionEvent::promise(ScriptState* state) const |
+{ |
+ v8::Local<v8::Value> value = m_promise.newLocal(state->isolate()); |
yurys
2015/06/18 13:03:21
Should there be a check that the promise is not pa
jochen (gone - plz use gerrit)
2015/06/18 13:25:23
if you manage to get the event in a different cont
|
+ return ScriptPromise(state, value); |
+} |
+ |
+ScriptValue PromiseRejectionEvent::reason(ScriptState* state) const |
+{ |
+ v8::Local<v8::Value> value = m_reason.newLocal(state->isolate()); |
+ return ScriptValue(state, value); |
+} |
const AtomicString& PromiseRejectionEvent::interfaceName() const |
{ |
@@ -35,4 +51,14 @@ DEFINE_TRACE(PromiseRejectionEvent) |
Event::trace(visitor); |
} |
+void PromiseRejectionEvent::didCollectPromise(const v8::WeakCallbackInfo<PromiseRejectionEvent>& data) |
+{ |
+ data.GetParameter()->m_promise.clear(); |
+} |
+ |
+void PromiseRejectionEvent::didCollectReason(const v8::WeakCallbackInfo<PromiseRejectionEvent>& data) |
+{ |
+ data.GetParameter()->m_reason.clear(); |
+} |
+ |
} // namespace blink |