Chromium Code Reviews| Index: Source/core/xmlhttprequest/XMLHttpRequest.cpp |
| diff --git a/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/Source/core/xmlhttprequest/XMLHttpRequest.cpp |
| index 239b35139a9d28652532e21320bec285f22c2ebf..3f6516ece7e0562f9a6d74efd6c59ea3981a876b 100644 |
| --- a/Source/core/xmlhttprequest/XMLHttpRequest.cpp |
| +++ b/Source/core/xmlhttprequest/XMLHttpRequest.cpp |
| @@ -832,11 +832,30 @@ void XMLHttpRequest::sendForInspectorXHRReplay(PassRefPtr<FormData> formData, Ex |
| m_exceptionCode = exceptionState.code(); |
| } |
| +void XMLHttpRequest::throwForLoadFailureIfNeeded(ExceptionState& exceptionState, const String& reason) |
| +{ |
| + if (m_error && !m_exceptionCode) |
| + m_exceptionCode = NetworkError; |
|
sof
2015/07/14 07:07:01
Add an early return if !m_exceptionCode ?
tyoshino (SeeGerritForStatus)
2015/07/14 08:48:55
Done.
|
| + |
| + String message = "Failed to load '" + m_url.elidedString() + "'"; |
| + if (!message.isNull()) { |
| + message.append(": "); |
| + message.append(reason); |
| + } |
| + |
| + if (m_exceptionCode) |
| + exceptionState.throwDOMException(m_exceptionCode, message); |
| +} |
| + |
| void XMLHttpRequest::createRequest(PassRefPtr<FormData> httpBody, ExceptionState& exceptionState) |
| { |
| // Only GET request is supported for blob URL. |
| if (m_url.protocolIs("blob") && m_method != "GET") { |
| - exceptionState.throwDOMException(NetworkError, "'GET' is the only method allowed for 'blob:' URLs."); |
| + handleNetworkError(); |
| + |
| + if (!m_async) { |
| + throwForLoadFailureIfNeeded(exceptionState, "'GET' is the only method allowed for 'blob:' URLs."); |
| + } |
| return; |
| } |
| @@ -911,16 +930,15 @@ void XMLHttpRequest::createRequest(PassRefPtr<FormData> httpBody, ExceptionState |
| // FIXME: Maybe create() can return null for other reasons too? |
| ASSERT(!m_loader); |
| m_loader = ThreadableLoader::create(executionContext, this, request, options, resourceLoaderOptions); |
| - } else { |
| - // Use count for XHR synchronous requests. |
| - UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous); |
| - ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options, resourceLoaderOptions); |
| + |
| + return; |
| } |
| - if (!m_exceptionCode && m_error) |
| - m_exceptionCode = NetworkError; |
| - if (m_exceptionCode) |
| - exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m_url.elidedString() + "'."); |
| + // Use count for XHR synchronous requests. |
| + UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous); |
| + ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options, resourceLoaderOptions); |
| + |
| + throwForLoadFailureIfNeeded(exceptionState, String()); |
| } |
| void XMLHttpRequest::abort() |