#include "config.h"
#include "V8XMLHttpRequest.h"
+#include "ArrayBuffer.h"
#include "Frame.h"
#include "InspectorInstrumentation.h"
+#include "V8ArrayBuffer.h"
#include "V8Binding.h"
#include "V8Blob.h"
#include "V8DOMFormData.h"
return v8String(text);
}
+v8::Handle<v8::Value> V8XMLHttpRequest::responseAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+ INC_STATS("DOM.XMLHttpRequest.response._get");
+ XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder());
+
+ switch (xmlHttpRequest->responseTypeCode()) {
+ case XMLHttpRequest::ResponseTypeDefault:
+ case XMLHttpRequest::ResponseTypeText:
+ return responseTextAccessorGetter(name, info);
+
+ case XMLHttpRequest::ResponseTypeDocument:
+ {
+ ExceptionCode ec = 0;
+ Document* document = xmlHttpRequest->responseXML(ec);
+ if (ec) {
+ V8Proxy::setDOMException(ec);
+ return v8::Undefined();
+ }
+ return toV8(document);
+ }
+
+ case XMLHttpRequest::ResponseTypeBlob:
+#if ENABLE(XHR_RESPONSE_BLOB)
+ {
+ ExceptionCode ec = 0;
+ Blob* blob = xmlHttpRequest->responseBlob(ec);
+ if (ec) {
+ V8Proxy::setDOMException(ec);
+ return v8::Undefined();
+ }
+ return toV8(blob);
+ }
+#else
+ return v8::Undefined();
+#endif
+
+#if ENABLE(3D_CANVAS) || ENABLE(BLOB)
+ case XMLHttpRequest::ResponseTypeArrayBuffer:
+ {
+ ExceptionCode ec = 0;
+ ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer(ec);
+ if (ec) {
+ V8Proxy::setDOMException(ec);
+ return v8::Undefined();
+ }
+ return toV8(arrayBuffer);
+ }
+#endif
+ }
+
+ return v8::Undefined();
+}
+
v8::Handle<v8::Value> V8XMLHttpRequest::openCallback(const v8::Arguments& args)
{
INC_STATS("DOM.XMLHttpRequest.open()");
DOMFormData* domFormData = V8DOMFormData::toNative(object);
ASSERT(domFormData);
xmlHttpRequest->send(domFormData, ec);
+#if ENABLE(3D_CANVAS) || ENABLE(BLOB)
+ } else if (V8ArrayBuffer::HasInstance(arg)) {
+ v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
+ ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(object);
+ ASSERT(arrayBuffer);
+ xmlHttpRequest->send(arrayBuffer, ec);
+#endif
} else
xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), ec);
}