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();
}
Exemplo n.º 2
0
JSValue JSWorkerGlobalScope::importScripts(ExecState& state)
{
    if (!state.argumentCount())
        return jsUndefined();

    Vector<String> urls;
    for (unsigned i = 0; i < state.argumentCount(); ++i) {
        urls.append(valueToUSVString(&state, state.uncheckedArgument(i)));
        if (state.hadException())
            return jsUndefined();
    }
    ExceptionCode ec = 0;

    wrapped().importScripts(urls, ec);
    setDOMException(&state, ec);
    return jsUndefined();
}