Commit 00a46b95 authored by rniwa@webkit.org's avatar rniwa@webkit.org

Stop throwing DOM exceptions in internal 'XMLHttpRequest' response getters

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

Reviewed by Alexey Proskuryakov.

Merge https://chromium.googlesource.com/chromium/blink/+/c8188c21452501b68950a9fcc1f5cbc7b4de4df5

Unlike 'responseText' and 'responseXML', 'responseBlob' and
'responseArrayBuffer' are not exposed to JavaScript (they don't
appear in the IDL or in the specification). As they are only called from
custom bindings in response to a JavaScript call to the 'response' getter,
we can safely replace the exception-throwing code in the implementation
with an ASSERT that the request type is correct.

* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::response):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::responseBlob):
(WebCore::XMLHttpRequest::responseArrayBuffer):
* xml/XMLHttpRequest.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154800 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 36027480
2013-08-28 Ryosuke Niwa <rniwa@webkit.org>
Stop throwing DOM exceptions in internal 'XMLHttpRequest' response getters
https://bugs.webkit.org/show_bug.cgi?id=120446
Reviewed by Alexey Proskuryakov.
Merge https://chromium.googlesource.com/chromium/blink/+/c8188c21452501b68950a9fcc1f5cbc7b4de4df5
Unlike 'responseText' and 'responseXML', 'responseBlob' and
'responseArrayBuffer' are not exposed to JavaScript (they don't
appear in the IDL or in the specification). As they are only called from
custom bindings in response to a JavaScript call to the 'response' getter,
we can safely replace the exception-throwing code in the implementation
with an ASSERT that the request type is correct.
* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::response):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::responseBlob):
(WebCore::XMLHttpRequest::responseArrayBuffer):
* xml/XMLHttpRequest.h:
2013-08-28 Chris Curtis <chris_curtis@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=119548
......@@ -180,26 +180,10 @@ JSValue JSXMLHttpRequest::response(ExecState* exec) const
}
case XMLHttpRequest::ResponseTypeBlob:
{
ExceptionCode ec = 0;
Blob* blob = impl()->responseBlob(ec);
if (ec) {
setDOMException(exec, ec);
return jsUndefined();
}
return toJS(exec, globalObject(), blob);
}
return toJS(exec, globalObject(), impl()->responseBlob());
case XMLHttpRequest::ResponseTypeArrayBuffer:
{
ExceptionCode ec = 0;
ArrayBuffer* arrayBuffer = impl()->responseArrayBuffer(ec);
if (ec) {
setDOMException(exec, ec);
return jsUndefined();
}
return toJS(exec, globalObject(), arrayBuffer);
}
return toJS(exec, globalObject(), impl()->responseArrayBuffer());
}
return jsUndefined();
......
......@@ -277,12 +277,10 @@ Document* XMLHttpRequest::responseXML(ExceptionCode& ec)
return m_responseDocument.get();
}
Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec)
Blob* XMLHttpRequest::responseBlob()
{
if (m_responseTypeCode != ResponseTypeBlob) {
ec = INVALID_STATE_ERR;
return 0;
}
ASSERT(m_responseTypeCode == ResponseTypeBlob);
// We always return null before DONE.
if (m_state != DONE)
return 0;
......@@ -313,12 +311,9 @@ Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec)
return m_responseBlob.get();
}
ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec)
ArrayBuffer* XMLHttpRequest::responseArrayBuffer()
{
if (m_responseTypeCode != ResponseTypeArrayBuffer) {
ec = INVALID_STATE_ERR;
return 0;
}
ASSERT(m_responseTypeCode == ResponseTypeArrayBuffer);
if (m_state != DONE)
return 0;
......
......@@ -106,7 +106,7 @@ public:
String responseText(ExceptionCode&);
Document* responseXML(ExceptionCode&);
Document* optionalResponseXML() const { return m_responseDocument.get(); }
Blob* responseBlob(ExceptionCode&);
Blob* responseBlob();
Blob* optionalResponseBlob() const { return m_responseBlob.get(); }
#if ENABLE(XHR_TIMEOUT)
unsigned long timeout() const { return m_timeoutMilliseconds; }
......@@ -123,9 +123,9 @@ public:
void setResponseType(const String&, ExceptionCode&);
String responseType();
ResponseTypeCode responseTypeCode() const { return m_responseTypeCode; }
// response attribute has custom getter.
JSC::ArrayBuffer* responseArrayBuffer(ExceptionCode&);
JSC::ArrayBuffer* responseArrayBuffer();
JSC::ArrayBuffer* optionalResponseArrayBuffer() const { return m_responseArrayBuffer.get(); }
void setLastSendLineNumber(unsigned lineNumber) { m_lastSendLineNumber = lineNumber; }
......
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