Ejemplo n.º 1
0
TEST_F(ScriptPromiseTest, castPromise)
{
    ScriptPromise promise = ScriptPromiseResolver::create(scriptState())->promise();
    ScriptPromise newPromise = ScriptPromise::cast(scriptState(), promise.v8Value());

    ASSERT_FALSE(promise.isEmpty());
    EXPECT_EQ(promise.v8Value(), newPromise.v8Value());
}
Ejemplo n.º 2
0
TEST_F(ScriptPromiseTest, reject)
{
    String onFulfilled, onRejected;

    ScriptValue value = ScriptValue(scriptState(), v8String(isolate(), "hello"));
    ScriptPromise promise = ScriptPromise::reject(scriptState(), ScriptValue(value));
    promise.then(Function::create(isolate(), &onFulfilled), Function::create(isolate(), &onRejected));

    ASSERT_FALSE(promise.isEmpty());
    ASSERT_TRUE(promise.v8Value()->IsPromise());

    EXPECT_EQ(String(), onFulfilled);
    EXPECT_EQ(String(), onRejected);

    isolate()->RunMicrotasks();

    EXPECT_EQ(String(), onFulfilled);
    EXPECT_EQ("hello", onRejected);
}