Title: [154800] trunk/Source/WebCore
Revision
154800
Author
[email protected]
Date
2013-08-28 18:13:07 -0700 (Wed, 28 Aug 2013)

Log Message

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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (154799 => 154800)


--- trunk/Source/WebCore/ChangeLog	2013-08-29 01:11:18 UTC (rev 154799)
+++ trunk/Source/WebCore/ChangeLog	2013-08-29 01:13:07 UTC (rev 154800)
@@ -1,3 +1,26 @@
+2013-08-28  Ryosuke Niwa  <[email protected]>
+
+        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  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=119548

Modified: trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp (154799 => 154800)


--- trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp	2013-08-29 01:11:18 UTC (rev 154799)
+++ trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp	2013-08-29 01:13:07 UTC (rev 154800)
@@ -180,26 +180,10 @@
         }
 
     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();

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (154799 => 154800)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2013-08-29 01:11:18 UTC (rev 154799)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2013-08-29 01:13:07 UTC (rev 154800)
@@ -277,12 +277,10 @@
     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 @@
     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;

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.h (154799 => 154800)


--- trunk/Source/WebCore/xml/XMLHttpRequest.h	2013-08-29 01:11:18 UTC (rev 154799)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.h	2013-08-29 01:13:07 UTC (rev 154800)
@@ -106,7 +106,7 @@
     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 @@
     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; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to