Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: Source/bindings/core/v8/custom/V8PromiseRejectionEventCustom.cpp

Issue 1181353005: Return null when no promise/reason is given in PromiseRejectionEvent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: updates Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "config.h"
6 #include "bindings/core/v8/V8PromiseRejectionEvent.h"
7
8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/ScriptValue.h"
11 #include "bindings/core/v8/V8Binding.h"
12
13 namespace blink {
14
15 void V8PromiseRejectionEvent::promiseAttributeGetterCustom(const v8::FunctionCal lbackInfo<v8::Value>& info)
16 {
17 v8::Isolate* isolate = info.GetIsolate();
18 PromiseRejectionEvent* event = V8PromiseRejectionEvent::toImpl(info.Holder() );
19 ScriptPromise promise = event->promise(ScriptState::current(isolate));
20 if (promise.isEmpty()) {
21 v8SetReturnValue(info, v8::Null(isolate));
22 return;
23 }
24
25 v8SetReturnValue(info, promise.v8Value());
26 }
27
28 void V8PromiseRejectionEvent::reasonAttributeGetterCustom(const v8::FunctionCall backInfo<v8::Value>& info)
29 {
30 v8::Isolate* isolate = info.GetIsolate();
31 PromiseRejectionEvent* event = V8PromiseRejectionEvent::toImpl(info.Holder() );
32 ScriptValue reason = event->reason(ScriptState::current(isolate));
33 if (reason.isEmpty()) {
34 v8SetReturnValue(info, v8::Null(isolate));
35 return;
36 }
37
38 v8SetReturnValue(info, reason.v8Value());
39 }
40
41 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698