Chromium Code Reviews| Index: Source/bindings/core/v8/custom/V8PromiseRejectionEventCustom.cpp |
| diff --git a/Source/bindings/core/v8/custom/V8PromiseRejectionEventCustom.cpp b/Source/bindings/core/v8/custom/V8PromiseRejectionEventCustom.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cfb6e80c3b1fab2e09a51c23fca9eb28bb52c589 |
| --- /dev/null |
| +++ b/Source/bindings/core/v8/custom/V8PromiseRejectionEventCustom.cpp |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "bindings/core/v8/V8PromiseRejectionEvent.h" |
| + |
| +#include "bindings/core/v8/DOMWrapperWorld.h" |
| +#include "bindings/core/v8/ScriptPromise.h" |
| +#include "bindings/core/v8/ScriptState.h" |
| +#include "bindings/core/v8/ScriptValue.h" |
| +#include "bindings/core/v8/V8Binding.h" |
| + |
| +namespace blink { |
| + |
| +void V8PromiseRejectionEvent::promiseAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info) |
| +{ |
| + v8::Isolate* isolate = info.GetIsolate(); |
| + PromiseRejectionEvent* event = V8PromiseRejectionEvent::toImpl(info.Holder()); |
| + ScriptPromise promise = event->promise(); |
| + if (promise.isEmpty() || promise.scriptValue().scriptState()->world().worldId() != ScriptState::current(isolate)->world().worldId()) { |
|
haraken
2015/06/19 12:17:32
Sorry for an iterative comment...
By moving this
|
| + // Return null when the promise is accessed by a different world than the world that created the promise. |
| + v8SetReturnValue(info, v8::Null(isolate)); |
| + return; |
| + } |
| + |
| + v8SetReturnValue(info, promise.v8Value()); |
| +} |
| + |
| +void V8PromiseRejectionEvent::reasonAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info) |
| +{ |
| + v8::Isolate* isolate = info.GetIsolate(); |
| + PromiseRejectionEvent* event = V8PromiseRejectionEvent::toImpl(info.Holder()); |
| + ScriptValue reason = event->reason(); |
| + if (reason.isEmpty() || reason.scriptState()->world().worldId() != ScriptState::current(isolate)->world().worldId()) { |
| + // Return null when the value is accessed by a different world than the world that created the value. |
| + v8SetReturnValue(info, v8::Null(isolate)); |
| + return; |
| + } |
| + |
| + v8SetReturnValue(info, reason.v8Value()); |
| +} |
| + |
| +} // namespace blink |