Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/DOMWrapperWorld.h" | |
| 9 #include "bindings/core/v8/ScriptPromise.h" | |
| 10 #include "bindings/core/v8/ScriptState.h" | |
| 11 #include "bindings/core/v8/ScriptValue.h" | |
| 12 #include "bindings/core/v8/V8Binding.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 void V8PromiseRejectionEvent::promiseAttributeGetterCustom(const v8::PropertyCal lbackInfo<v8::Value>& info) | |
| 17 { | |
| 18 v8::Isolate* isolate = info.GetIsolate(); | |
| 19 PromiseRejectionEvent* event = V8PromiseRejectionEvent::toImpl(info.Holder() ); | |
| 20 ScriptPromise promise = event->promise(); | |
| 21 if (promise.isEmpty() || promise.scriptValue().scriptState()->world().worldI d() != ScriptState::current(isolate)->world().worldId()) { | |
|
haraken
2015/06/19 12:17:32
Sorry for an iterative comment...
By moving this
| |
| 22 // Return null when the promise is accessed by a different world than th e world that created the promise. | |
| 23 v8SetReturnValue(info, v8::Null(isolate)); | |
| 24 return; | |
| 25 } | |
| 26 | |
| 27 v8SetReturnValue(info, promise.v8Value()); | |
| 28 } | |
| 29 | |
| 30 void V8PromiseRejectionEvent::reasonAttributeGetterCustom(const v8::PropertyCall backInfo<v8::Value>& info) | |
| 31 { | |
| 32 v8::Isolate* isolate = info.GetIsolate(); | |
| 33 PromiseRejectionEvent* event = V8PromiseRejectionEvent::toImpl(info.Holder() ); | |
| 34 ScriptValue reason = event->reason(); | |
| 35 if (reason.isEmpty() || reason.scriptState()->world().worldId() != ScriptSta te::current(isolate)->world().worldId()) { | |
| 36 // Return null when the value is accessed by a different world than the world that created the value. | |
| 37 v8SetReturnValue(info, v8::Null(isolate)); | |
| 38 return; | |
| 39 } | |
| 40 | |
| 41 v8SetReturnValue(info, reason.v8Value()); | |
| 42 } | |
| 43 | |
| 44 } // namespace blink | |
| OLD | NEW |