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

Unified Diff: Source/bindings/v8/custom/V8PromiseCustom.cpp

Issue 18648011: Implement Promise.fulfill, Promise.resolve and Promise.reject. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 7 years, 5 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 | « LayoutTests/fast/js/Promise-static-resolve-expected.txt ('k') | Source/core/dom/Promise.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/custom/V8PromiseCustom.cpp
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.cpp b/Source/bindings/v8/custom/V8PromiseCustom.cpp
index 671a6cfa8e87ee7f3f0407b6cf3fa905630b20bd..1a98b8c5acdf22c03636408693f32b469d69f796 100644
--- a/Source/bindings/v8/custom/V8PromiseCustom.cpp
+++ b/Source/bindings/v8/custom/V8PromiseCustom.cpp
@@ -389,6 +389,45 @@ void V8Promise::catchMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& arg
v8SetReturnValue(args, promise);
}
+void V8Promise::fulfillMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::Local<v8::Value> result = v8::Undefined(isolate);
+ if (args.Length() > 0)
+ result = args[0];
+
+ v8::Local<v8::Object> promise, resolver;
+ V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
+ V8PromiseCustom::fulfillResolver(resolver, result, V8PromiseCustom::Asynchronous, isolate);
+ v8SetReturnValue(args, promise);
+}
+
+void V8Promise::resolveMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::Local<v8::Value> result = v8::Undefined(isolate);
+ if (args.Length() > 0)
+ result = args[0];
+
+ v8::Local<v8::Object> promise, resolver;
+ V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
+ V8PromiseCustom::resolveResolver(resolver, result, V8PromiseCustom::Asynchronous, isolate);
+ v8SetReturnValue(args, promise);
+}
+
+void V8Promise::rejectMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::Local<v8::Value> result = v8::Undefined(isolate);
+ if (args.Length() > 0)
+ result = args[0];
+
+ v8::Local<v8::Object> promise, resolver;
+ V8PromiseCustom::createPromise(args.Holder(), &promise, &resolver, isolate);
+ V8PromiseCustom::rejectResolver(resolver, result, V8PromiseCustom::Asynchronous, isolate);
+ v8SetReturnValue(args, promise);
+}
+
void V8Promise::anyMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = args.GetIsolate();
« no previous file with comments | « LayoutTests/fast/js/Promise-static-resolve-expected.txt ('k') | Source/core/dom/Promise.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698