JSValue JSXMLHttpRequest::send(ExecState& state)
{
    InspectorInstrumentation::willSendXMLHttpRequest(wrapped().scriptExecutionContext(), wrapped().url());

    ExceptionCode ec = 0;
    JSValue val = state.argument(0);
    if (val.isUndefinedOrNull())
        wrapped().send(ec);
    else if (val.inherits(JSDocument::info()))
        wrapped().send(JSDocument::toWrapped(val), ec);
    else if (val.inherits(JSBlob::info()))
        wrapped().send(JSBlob::toWrapped(val), ec);
    else if (val.inherits(JSDOMFormData::info()))
        wrapped().send(JSDOMFormData::toWrapped(val), ec);
    else if (val.inherits(JSArrayBuffer::info()))
        wrapped().send(toArrayBuffer(val), ec);
    else if (val.inherits(JSArrayBufferView::info())) {
        RefPtr<ArrayBufferView> view = toArrayBufferView(val);
        wrapped().send(view.get(), ec);
    } else
        wrapped().send(val.toString(&state)->value(&state), ec);

    // FIXME: This should probably use ShadowChicken so that we get the right frame even when it did
    // a tail call.
    // https://bugs.webkit.org/show_bug.cgi?id=155688
    SendFunctor functor;
    state.iterate(functor);
    wrapped().setLastSendLineAndColumnNumber(functor.line(), functor.column());
    wrapped().setLastSendURL(functor.url());
    setDOMException(&state, ec);
    return jsUndefined();
}
Ejemplo n.º 2
0
JSValue JSXMLHttpRequest::send(ExecState* exec)
{
    InspectorInstrumentation::willSendXMLHttpRequest(impl().scriptExecutionContext(), impl().url());

    ExceptionCode ec = 0;
    JSValue val = exec->argument(0);
    if (val.isUndefinedOrNull())
        impl().send(ec);
    else if (val.inherits(JSDocument::info()))
        impl().send(toDocument(val), ec);
    else if (val.inherits(JSBlob::info()))
        impl().send(toBlob(val), ec);
    else if (val.inherits(JSDOMFormData::info()))
        impl().send(toDOMFormData(val), ec);
    else if (val.inherits(JSArrayBuffer::info()))
        impl().send(toArrayBuffer(val), ec);
    else if (val.inherits(JSArrayBufferView::info())) {
        RefPtr<ArrayBufferView> view = toArrayBufferView(val);
        impl().send(view.get(), ec);
    } else
        impl().send(val.toString(exec)->value(exec), ec);

    SendFunctor functor;
    exec->iterate(functor);
    impl().setLastSendLineNumber(functor.line());
    impl().setLastSendURL(functor.url());
    setDOMException(exec, ec);
    return jsUndefined();
}