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

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
Index: Source/core/testing/Internals.cpp
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index 35e8ee2f5ac32dd40bc3d67d125827f1c6de25e6..05c3fe2d9118da9de96341eb980f4e74c970e710 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"
@@ -2381,6 +2382,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));

Powered by Google App Engine
This is Rietveld 408576698