From be01689f43cf6882cf670d33df49ead1f570c53a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sun, 27 May 2012 21:51:42 +0200 Subject: Imported WebKit commit 8d6c5efc74f0222dfc7bcce8d845d4a2707ed9e6 (http://svn.webkit.org/repository/webkit/trunk@118629) --- Source/WebCore/xml/XMLHttpRequest.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'Source/WebCore/xml/XMLHttpRequest.cpp') diff --git a/Source/WebCore/xml/XMLHttpRequest.cpp b/Source/WebCore/xml/XMLHttpRequest.cpp index 0e9e0ab4b..be6b4c698 100644 --- a/Source/WebCore/xml/XMLHttpRequest.cpp +++ b/Source/WebCore/xml/XMLHttpRequest.cpp @@ -484,14 +484,22 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc return; } - // Newer functionality is not available to synchronous requests in window contexts, as a spec-mandated - // attempt to discourage synchronous XHR use. responseType is one such piece of functionality. - // We'll only disable this functionality for HTTP(S) requests since sync requests for local protocols - // such as file: and data: still make sense to allow. - if (!async && scriptExecutionContext()->isDocument() && url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDefault) { - logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) requests made from the window context cannot have XMLHttpRequest.responseType set."); - ec = INVALID_ACCESS_ERR; - return; + if (!async && scriptExecutionContext()->isDocument()) { + if (!document()->settings()->syncXHRInDocumentsEnabled()) { + logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpRequests cannot be made in the current window context."); + ec = INVALID_ACCESS_ERR; + return; + } + + // Newer functionality is not available to synchronous requests in window contexts, as a spec-mandated + // attempt to discourage synchronous XHR use. responseType is one such piece of functionality. + // We'll only disable this functionality for HTTP(S) requests since sync requests for local protocols + // such as file: and data: still make sense to allow. + if (url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDefault) { + logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) requests made from the window context cannot have XMLHttpRequest.responseType set."); + ec = INVALID_ACCESS_ERR; + return; + } } m_method = uppercaseKnownHTTPMethod(method); -- cgit v1.2.1