Ejemplo n.º 1
0
TEST_F(ReadableStreamTest, Start)
{
    ScriptState::Scope scope(scriptState());
    ExceptionState exceptionState(ExceptionState::ConstructionContext, "property", "interface", scriptState()->context()->Global(), isolate());
    Checkpoint checkpoint;
    {
        InSequence s;
        EXPECT_CALL(checkpoint, Call(0));
        EXPECT_CALL(*m_underlyingSource, pullSource()).Times(1);
        EXPECT_CALL(checkpoint, Call(1));
    }

    StringStream* stream = new StringStream(m_underlyingSource);
    EXPECT_FALSE(exceptionState.hadException());
    EXPECT_FALSE(stream->isStarted());
    EXPECT_FALSE(stream->isDraining());
    EXPECT_FALSE(stream->isPulling());
    EXPECT_FALSE(stream->isDisturbed());
    EXPECT_EQ(stream->stateInternal(), ReadableStream::Readable);

    checkpoint.Call(0);
    stream->didSourceStart();
    checkpoint.Call(1);

    EXPECT_TRUE(stream->isStarted());
    EXPECT_FALSE(stream->isDraining());
    EXPECT_TRUE(stream->isPulling());
    EXPECT_EQ(stream->stateInternal(), ReadableStream::Readable);

    // We need to call |error| in order to make
    // ActiveDOMObject::hasPendingActivity return false.
    stream->error(DOMException::create(AbortError, "done"));
}
Ejemplo n.º 2
0
TEST_F(ReadableStreamTest, StartFail)
{
    ScriptState::Scope scope(scriptState());
    ExceptionState exceptionState(ExceptionState::ConstructionContext, "property", "interface", scriptState()->context()->Global(), isolate());
    StringStream* stream = new StringStream(m_underlyingSource);
    EXPECT_FALSE(exceptionState.hadException());
    EXPECT_FALSE(stream->isStarted());
    EXPECT_FALSE(stream->isDraining());
    EXPECT_FALSE(stream->isPulling());
    EXPECT_EQ(stream->stateInternal(), ReadableStream::Readable);

    stream->error(DOMException::create(NotFoundError));

    EXPECT_FALSE(stream->isStarted());
    EXPECT_FALSE(stream->isDraining());
    EXPECT_FALSE(stream->isPulling());
    EXPECT_EQ(stream->stateInternal(), ReadableStream::Errored);
}