Stop throwing DOM exceptions in internal 'XMLHttpRequest' response getters
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Aug 2013 01:13:07 +0000 (01:13 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Aug 2013 01:13:07 +0000 (01:13 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@154800 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XMLHttpRequest.h

index baebb00af5c8f8acbc3044eced986bd27d7b2a1e..ebd33cfb195de51e3d0176dbe35efea4d48ed31d 100644 (file)
@@ -1,3 +1,26 @@
+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
index 66ae3dc3c98ac248c38c9328968871bf1718223b..229aa0ebebd65ffef616e90ab6f12db0dd9190b0 100644 (file)
@@ -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();
index fd81970c5467799f6806eddb638c66114737d6d7..c810536a93558063ca7aa44209c0caa6dbb6b7a3 100644 (file)
@@ -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;
index 2063b4edfebf7f13b10917c6e11e6d2eac8b7b3e..41948ffdd86536e320e7e9d94457b87635425309 100644 (file)
@@ -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; }