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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/core/v8/RejectedPromises.cpp ('k') | Source/bindings/core/v8/custom/custom.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/bindings/core/v8/RejectedPromises.cpp ('k') | Source/bindings/core/v8/custom/custom.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698