Chromium Code Reviews| Index: Source/core/testing/Internals.cpp |
| diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp |
| index 496ce9b74b23afd78761ea318afb578b5480d068..7d24d9141391aa8598e11aca4255f7cef39b854d 100644 |
| --- a/Source/core/testing/Internals.cpp |
| +++ b/Source/core/testing/Internals.cpp |
| @@ -39,6 +39,8 @@ |
| #include "RuntimeEnabledFeatures.h" |
| #include "TypeConversions.h" |
| #include "bindings/v8/ExceptionState.h" |
| +#include "bindings/v8/ScriptFunction.h" |
| +#include "bindings/v8/ScriptPromise.h" |
| #include "bindings/v8/SerializedScriptValue.h" |
| #include "bindings/v8/V8ThrowException.h" |
| #include "core/animation/DocumentTimeline.h" |
| @@ -2153,4 +2155,35 @@ bool Internals::loseSharedGraphicsContext3D() |
| return true; |
| } |
| +namespace { |
| + |
| +class AddOneFunction : public ScriptFunction { |
| +public: |
| + static v8::Handle<v8::Function> create() |
| + { |
| + AddOneFunction* function = new AddOneFunction; |
| + return function->releaseToV8Function(); |
|
abarth-chromium
2013/08/19 22:03:19
I'm not 100% happy with this line. I'd rather if
|
| + } |
| + |
| +private: |
| + virtual ScriptValue call(ScriptValue value) OVERRIDE |
| + { |
| + v8::Local<v8::Value> v8Value = value.v8Value(); |
| + ASSERT(v8Value->IsNumber()); |
| + int intValue = v8Value.As<v8::Integer>()->Value(); |
| + ScriptValue result = ScriptValue(v8::Integer::New(intValue + 1)); |
| + return result; |
| + } |
| +}; |
| + |
| +} |
| + |
| +ScriptValue Internals::addOneToPromise(ScriptValue promise) |
| +{ |
| + ScriptValue result; |
| + bool success = ScriptPromise(promise).then(AddOneFunction::create(), result); |
| + RELEASE_ASSERT(success); |
| + return result; |
| +} |
| + |
| } |