static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecState& state)
{
    const String& typeArg = state.argument(0).toString(&state)->value(&state);
    bool canBubbleArg = state.argument(1).toBoolean(&state);
    bool cancelableArg = state.argument(2).toBoolean(&state);
    const String originArg = valueToUSVString(&state, state.argument(4));
    const String lastEventIdArg = state.argument(5).toString(&state)->value(&state);
    DOMWindow* sourceArg = JSDOMWindow::toWrapped(state, state.argument(6));
    std::unique_ptr<MessagePortArray> messagePorts;
    std::unique_ptr<ArrayBufferArray> arrayBuffers;
    if (!state.argument(7).isUndefinedOrNull()) {
        messagePorts = std::make_unique<MessagePortArray>();
        arrayBuffers = std::make_unique<ArrayBufferArray>();
        fillMessagePortArray(state, state.argument(7), *messagePorts, *arrayBuffers);
        if (state.hadException())
            return jsUndefined();
    }
    Deprecated::ScriptValue dataArg(state.vm(), state.argument(3));
    if (state.hadException())
        return jsUndefined();

    MessageEvent& event = jsEvent->wrapped();
    event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, sourceArg, WTFMove(messagePorts));
    jsEvent->m_data.set(state.vm(), jsEvent, dataArg.jsValue());
    return jsUndefined();
}
Esempio n. 2
0
void ReadableJSStream::error(JSC::ExecState& state, ExceptionCode& ec)
{
    if (!isReadable()) {
        ec = TypeError;
        return;
    }
    storeError(state, state.argument(0));
}
Esempio n. 3
0
static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecState& state)
{
    VM& vm = state.vm();
    auto scope = DECLARE_THROW_SCOPE(vm);

    const String& typeArg = state.argument(0).toWTFString(&state);
    RETURN_IF_EXCEPTION(scope, JSValue());

    bool canBubbleArg = state.argument(1).toBoolean(&state);
    RETURN_IF_EXCEPTION(scope, JSValue());

    bool cancelableArg = state.argument(2).toBoolean(&state);
    RETURN_IF_EXCEPTION(scope, JSValue());

    JSValue dataArg = state.argument(3);

    const String originArg = convert<IDLUSVString>(state, state.argument(4));
    RETURN_IF_EXCEPTION(scope, JSValue());

    const String lastEventIdArg = state.argument(5).toWTFString(&state);
    RETURN_IF_EXCEPTION(scope, JSValue());

    auto sourceArg = convert<IDLNullable<IDLUnion<IDLInterface<DOMWindow>, IDLInterface<MessagePort>>>>(state, state.argument(6));
    RETURN_IF_EXCEPTION(scope, JSValue());
    
    Vector<RefPtr<MessagePort>> messagePorts;
    if (!state.argument(7).isUndefinedOrNull()) {
        messagePorts = convert<IDLSequence<IDLInterface<MessagePort>>>(state, state.argument(7));
        RETURN_IF_EXCEPTION(scope, JSValue());
    }

    MessageEvent& event = jsEvent->wrapped();
    event.initMessageEvent(state, typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, WTFMove(sourceArg), WTFMove(messagePorts));
    jsEvent->m_data.set(vm, jsEvent, dataArg);
    return jsUndefined();
}