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

Unified Diff: Source/core/testing/Internals.cpp

Issue 197213007: ScriptPromise implementation for V8 Promises (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/testing/Internals.cpp
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index 65bd2e614f46fe1463efcd8805cd0b9aae2a3ed1..2d4b150b353643fe93ad576e86afc9ef9ba2e311 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -42,6 +42,7 @@
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/ScriptFunction.h"
#include "bindings/v8/ScriptPromise.h"
+#include "bindings/v8/ScriptPromiseResolver.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8ThrowException.h"
#include "core/animation/DocumentTimeline.h"
@@ -2380,6 +2381,27 @@ private:
} // namespace
+ScriptPromise Internals::createPromise(ExecutionContext* context)
+{
+ return ScriptPromiseResolver::create(context)->promise();
+}
+
+ScriptPromise Internals::createResolvedPromise(ExecutionContext* context, ScriptValue value)
+{
+ RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(context);
+ ScriptPromise promise = resolver->promise();
+ resolver->resolve(value);
+ return promise;
+}
+
+ScriptPromise Internals::createRejectedPromise(ExecutionContext* context, ScriptValue value)
+{
+ RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(context);
+ ScriptPromise promise = resolver->promise();
+ resolver->reject(value);
+ return promise;
+}
+
ScriptPromise Internals::addOneToPromise(ExecutionContext* context, ScriptPromise promise)
{
return promise.then(AddOneFunction::create(context));
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698