Changeset 103675 in webkit


Ignore:
Timestamp:
Dec 25, 2011, 8:02:21 PM (14 years ago)
Author:
[email protected]
Message:

Allow XMLHttpRequest responseType to be set at any state up to and including HEADERS_RECEIVED
https://bugs.webkit.org/show_bug.cgi?id=75190

Source/WebCore:

XMLHttpRequest.responseType should be modifiable at any state up to and including the
HEADERS_RECEIVED state. Therefore, subsequent calls to open() should not reset responseType
to its default value, and calls to open() must follow the same spec mandate set forth in
setResponseType() for synchronous HTTP(S) requests made from the window context.

Reviewed by Alexey Proskuryakov.

Tests: fast/xmlhttprequest/xmlhttprequest-responsetype-before-open-sync-request.html

fast/xmlhttprequest/xmlhttprequest-responsetype-before-open.html
fast/xmlhttprequest/xmlhttprequest-responsetype-set-at-headers-received.html

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::setResponseType):
Prevent setting the value only when in LOADING and DONE states. No longer check if
m_loader is present, which is instantiated on a call to send(), because responseType
can be safely changed after a request is sent.
(WebCore::XMLHttpRequest::open):
Do not reset m_responseTypeCode to the default value, and prevent calls to open()
for synchronous HTTP(S) requests made from the window context when m_responseTypeCode
is not the default value.

LayoutTests:

Reviewed by Alexey Proskuryakov.

  • fast/xmlhttprequest/xmlhttprequest-responsetype-before-open-expected.txt: Added.
  • fast/xmlhttprequest/xmlhttprequest-responsetype-before-open-sync-request-expected.txt: Added.
  • fast/xmlhttprequest/xmlhttprequest-responsetype-before-open-sync-request.html: Added.

Validate that calls to open() for synchronous HTTP(S) requests from the window context will
properly fail when responseType has been previously set to a non-default value.

  • fast/xmlhttprequest/xmlhttprequest-responsetype-before-open.html: Added.

Validate that XMLHttpRequest.responseType can be set prior to a call to open().

  • fast/xmlhttprequest/xmlhttprequest-responsetype-set-at-headers-received-expected.txt: Added.
  • fast/xmlhttprequest/xmlhttprequest-responsetype-set-at-headers-received.html: Added.

Validate that XMLHttpRequest.responseType can be set at the HEADERS_RECEIVED state, but
no state later than that.

Location:
trunk
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r103661 r103675  
     12011-12-24  Jarred Nicholls  <[email protected]>
     2
     3        Allow XMLHttpRequest responseType to be set at any state up to and including HEADERS_RECEIVED
     4        https://bugs.webkit.org/show_bug.cgi?id=75190
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * fast/xmlhttprequest/xmlhttprequest-responsetype-before-open-expected.txt: Added.
     9        * fast/xmlhttprequest/xmlhttprequest-responsetype-before-open-sync-request-expected.txt: Added.
     10        * fast/xmlhttprequest/xmlhttprequest-responsetype-before-open-sync-request.html: Added.
     11        Validate that calls to open() for synchronous HTTP(S) requests from the window context will
     12        properly fail when responseType has been previously set to a non-default value.
     13        * fast/xmlhttprequest/xmlhttprequest-responsetype-before-open.html: Added.
     14        Validate that XMLHttpRequest.responseType can be set prior to a call to open().
     15        * fast/xmlhttprequest/xmlhttprequest-responsetype-set-at-headers-received-expected.txt: Added.
     16        * fast/xmlhttprequest/xmlhttprequest-responsetype-set-at-headers-received.html: Added.
     17        Validate that XMLHttpRequest.responseType can be set at the HEADERS_RECEIVED state, but
     18        no state later than that.
     19
    1202011-12-24  Jarred Nicholls  <[email protected]>
    221
  • trunk/Source/WebCore/ChangeLog

    r103673 r103675  
     12011-12-24  Jarred Nicholls  <[email protected]>
     2
     3        Allow XMLHttpRequest responseType to be set at any state up to and including HEADERS_RECEIVED
     4        https://bugs.webkit.org/show_bug.cgi?id=75190
     5
     6        XMLHttpRequest.responseType should be modifiable at any state up to and including the
     7        HEADERS_RECEIVED state. Therefore, subsequent calls to open() should not reset responseType
     8        to its default value, and calls to open() must follow the same spec mandate set forth in
     9        setResponseType() for synchronous HTTP(S) requests made from the window context.
     10
     11        Reviewed by Alexey Proskuryakov.
     12
     13        Tests: fast/xmlhttprequest/xmlhttprequest-responsetype-before-open-sync-request.html
     14               fast/xmlhttprequest/xmlhttprequest-responsetype-before-open.html
     15               fast/xmlhttprequest/xmlhttprequest-responsetype-set-at-headers-received.html
     16
     17        * xml/XMLHttpRequest.cpp:
     18        (WebCore::XMLHttpRequest::setResponseType):
     19        Prevent setting the value only when in LOADING and DONE states. No longer check if
     20        m_loader is present, which is instantiated on a call to send(), because responseType
     21        can be safely changed after a request is sent.
     22        (WebCore::XMLHttpRequest::open):
     23        Do not reset m_responseTypeCode to the default value, and prevent calls to open()
     24        for synchronous HTTP(S) requests made from the window context when m_responseTypeCode
     25        is not the default value.
     26
    1272011-12-25  Sam Weinig  <[email protected]>
    228
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r103661 r103675  
    293293void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& ec)
    294294{
    295     if (m_state != OPENED || m_loader) {
     295    if (m_state >= LOADING) {
    296296        ec = INVALID_STATE_ERR;
    297297        return;
     
    435435    m_state = UNSENT;
    436436    m_error = false;
    437     m_responseTypeCode = ResponseTypeDefault;
    438437    m_uploadComplete = false;
    439438
     
    457456        // FIXME: Should this be throwing an exception?
    458457        ec = SECURITY_ERR;
     458        return;
     459    }
     460
     461    // Newer functionality is not available to synchronous requests in window contexts, as a spec-mandated
     462    // attempt to discourage synchronous XHR use. responseType is one such piece of functionality.
     463    // We'll only disable this functionality for HTTP(S) requests since sync requests for local protocols
     464    // such as file: and data: still make sense to allow.
     465    if (!async && scriptExecutionContext()->isDocument() && url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDefault) {
     466        logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) requests made from the window context cannot have XMLHttpRequest.responseType set.");
     467        ec = INVALID_ACCESS_ERR;
    459468        return;
    460469    }
Note: See TracChangeset for help on using the changeset viewer.