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

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: 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/SerializedScriptValue.h"
9 #include "bindings/core/v8/SerializedScriptValueFactory.h"
10 #include "bindings/core/v8/V8HiddenValue.h"
11 #include "bindings/core/v8/V8History.h"
haraken 2015/06/18 17:52:09 This wouldn't be needed.
12 #include "core/events/PopStateEvent.h"
haraken 2015/06/18 17:52:08 Ditto.
13 #include "core/frame/History.h"
haraken 2015/06/18 17:52:09 Ditto.
14
15 namespace blink {
16
17 void V8PromiseRejectionEvent::promiseAttributeGetterCustom(const v8::PropertyCal lbackInfo<v8::Value>& info)
18 {
19 v8::Isolate* isolate = info.GetIsolate();
20 v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(isolate, info.Ho lder(), V8HiddenValue::promise(isolate));
haraken 2015/06/18 17:52:08 What is the point of setting a hidden value here?
jochen (gone - plz use gerrit) 2015/06/18 18:53:14 i should probably just return null if it's from a
haraken 2015/06/18 19:01:00 Ah, right! Maybe it would be better to have a comm
21
22 if (!result.IsEmpty()) {
23 v8SetReturnValue(info, result);
24 return;
25 }
26
27 PromiseRejectionEvent* event = V8PromiseRejectionEvent::toImpl(info.Holder() );
28 result = event->promise(isolate);
29 if (result.IsEmpty())
30 result = v8::Null(isolate);
31
32 V8HiddenValue::setHiddenValue(isolate, info.Holder(), V8HiddenValue::promise (isolate), result);
33
34 v8SetReturnValue(info, result);
35 }
36
37 void V8PromiseRejectionEvent::reasonAttributeGetterCustom(const v8::PropertyCall backInfo<v8::Value>& info)
38 {
39 v8::Isolate* isolate = info.GetIsolate();
40 v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(isolate, info.Ho lder(), V8HiddenValue::reason(isolate));
haraken 2015/06/18 17:52:08 Ditto.
41
42 if (!result.IsEmpty()) {
43 v8SetReturnValue(info, result);
44 return;
45 }
46
47 PromiseRejectionEvent* event = V8PromiseRejectionEvent::toImpl(info.Holder() );
48 result = event->reason(isolate);
49 if (result.IsEmpty())
50 result = v8::Null(isolate);
51
52 V8HiddenValue::setHiddenValue(isolate, info.Holder(), V8HiddenValue::reason( isolate), result);
53
54 v8SetReturnValue(info, result);
55 }
56
57 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698