Commit 2617dfe8 authored by jianli@chromium.org's avatar jianli@chromium.org

Add send(ArrayBuffer) to XMLHttpRequest per XMLHttpRequest Level 2 spec

https://bugs.webkit.org/show_bug.cgi?id=50199

Reviewed by David Levin.

WebCore:

Test: http/tests/xmlhttprequest/send-array-buffer.html

* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::send):
* bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
(WebCore::V8XMLHttpRequest::sendCallback):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):
* xml/XMLHttpRequest.h:

LayoutTests:

* http/tests/xmlhttprequest/resources/post-echo-as-ascii.cgi: Added.
* http/tests/xmlhttprequest/send-array-buffer-expected.txt: Added.
* http/tests/xmlhttprequest/send-array-buffer.html: Added.
* platform/gtk/Skipped:
* platform/qt/Skipped:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72866 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b3644551
2010-11-29 Jian Li <jianli@chromium.org>
Reviewed by David Levin.
Add send(ArrayBuffer) to XMLHttpRequest per XMLHttpRequest Level 2 spec
https://bugs.webkit.org/show_bug.cgi?id=50199
* http/tests/xmlhttprequest/resources/post-echo-as-ascii.cgi: Added.
* http/tests/xmlhttprequest/send-array-buffer-expected.txt: Added.
* http/tests/xmlhttprequest/send-array-buffer.html: Added.
* platform/gtk/Skipped:
* platform/qt/Skipped:
2010-11-29 Xiaomei Ji <xji@chromium.org>
Unreviewed.
#!/usr/bin/perl -w
print "Content-type: text/plain\n\n";
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $request, $ENV{'CONTENT_LENGTH'})
|| die "Could not get query\n";
my @array = split //, $request;
@array = map(ord, @array);
print "@array";
} else {
print "Wrong method: " . $ENV{'REQUEST_METHOD'} . "\n";
}
Tests sending an array buffer.
0 1 2 48 49 50 128 129 130 253 254 255
<html>
<body>
Tests sending an array buffer.
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
var console_messages = document.createElement("ul");
document.body.appendChild(console_messages);
function log(message)
{
var item = document.createElement("li");
item.appendChild(document.createTextNode(message));
console_messages.appendChild(item);
}
var array = new Uint8Array([0, 1, 2, 48, 49, 50, 128, 129, 130, 253, 254, 255]);
var xhr = new XMLHttpRequest;
xhr.open("POST", "resources/post-echo-as-ascii.cgi", false);
xhr.send(array.buffer);
log(xhr.responseText);
</script>
</body>
</html>
......@@ -1109,6 +1109,7 @@ fast/xmlhttprequest/xmlhttprequest-responsetype-abort.html
fast/xmlhttprequest/xmlhttprequest-responsetype-arraybuffer.html
fast/xmlhttprequest/xmlhttprequest-responsetype-document.html
fast/xmlhttprequest/xmlhttprequest-responsetype-text.html
http/tests/xmlhttprequest/send-array-buffer.html
# https://bugs.webkit.org/show_bug.cgi?id=30508
# All these tests fail because WebKit does not work correctly with
......
......@@ -285,6 +285,7 @@ fast/xmlhttprequest/xmlhttprequest-responsetype-abort.html
fast/xmlhttprequest/xmlhttprequest-responsetype-arraybuffer.html
fast/xmlhttprequest/xmlhttprequest-responsetype-document.html
fast/xmlhttprequest/xmlhttprequest-responsetype-text.html
http/tests/xmlhttprequest/send-array-buffer.html
# Missing DRT ability to set accept cookie policy
http/tests/xmlhttprequest/cross-origin-cookie-storage.html
......
2010-11-29 Jian Li <jianli@chromium.org>
Reviewed by David Levin.
Add send(ArrayBuffer) to XMLHttpRequest per XMLHttpRequest Level 2 spec
https://bugs.webkit.org/show_bug.cgi?id=50199
Test: http/tests/xmlhttprequest/send-array-buffer.html
* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::send):
* bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
(WebCore::V8XMLHttpRequest::sendCallback):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):
* xml/XMLHttpRequest.h:
2010-11-29 James Robinson <jamesr@chromium.org>
[chromium] REGRESSION(72470): Crash in skia on some images
......@@ -124,6 +124,10 @@ JSValue JSXMLHttpRequest::send(ExecState* exec)
impl()->send(toBlob(val), ec);
else if (val.inherits(&JSDOMFormData::s_info))
impl()->send(toDOMFormData(val), ec);
#if ENABLE(3D_CANVAS) || ENABLE(BLOB)
else if (val.inherits(&JSArrayBuffer::s_info))
impl()->send(toArrayBuffer(val), ec);
#endif
else
impl()->send(ustringToString(val.toString(exec)), ec);
}
......
......@@ -193,6 +193,13 @@ v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args)
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);
}
......
......@@ -586,6 +586,22 @@ void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec)
createRequest(ec);
}
#if ENABLE(3D_CANVAS) || ENABLE(BLOB)
void XMLHttpRequest::send(ArrayBuffer* body, ExceptionCode& ec)
{
if (!initSend(ec))
return;
if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) {
m_requestEntityBody = FormData::create(body->data(), body->byteLength());
if (m_upload)
m_requestEntityBody->setAlwaysStream(true);
}
createRequest(ec);
}
#endif
void XMLHttpRequest::createRequest(ExceptionCode& ec)
{
#if ENABLE(BLOB)
......
......@@ -94,6 +94,9 @@ public:
void send(const String&, ExceptionCode&);
void send(Blob*, ExceptionCode&);
void send(DOMFormData*, ExceptionCode&);
#if ENABLE(3D_CANVAS) || ENABLE(BLOB)
void send(ArrayBuffer*, ExceptionCode&);
#endif
void abort();
void setRequestHeader(const AtomicString& name, const String& value, ExceptionCode&);
void overrideMimeType(const String& override);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment