Index of /test/apis/XMLHttpRequest

      Name                    Last modified      Size  Description
Parent Directory -
(Below are all conformance requirements that apply to UAs, hopefully.
Intended as a guide for writing test cases. Might be obsolete or wrong; see
the spec.)


must support at least these HTTP methods: GET POST HEAD PUT DELETE OPTIONS

support xml or responseXML must always be null


Objects implementing the XMLHttpRequest interface must also implement the
EventTarget interface. [DOM3Events]

Objects implementing the Window interface must provide an XMLHttpRequest()
constructor. [Window]

When the XMLHttpRequest() constructor is invoked a persistent pointer to
the associated Window object must be stored on the newly created object.

(This is the Window pointer. The associated Window object is the one
of which the XMLHttpRequest constructor was invoked.)

This pointer must persist even if the browsing context in which the Window
is located is destroyed (by removing it from a parent browsing context,
for instance).

An attribute that takes an EventListener as value that must be invoked
along with any other appropriate event listeners that are registered on
this object when a readystatechange event is dispatched on it.

readystatechange's initial value must be null.

readyState must be the value of the constant corresponding to the object's
current state.


when open(method, url, async, user, password) is invoked, the user agent
must follow the following steps:

 1. If the method argument doesn't match the Method production defined in
    section 5.1.1 of RFC 2616 the user agent must raise a SYNTAX_ERR
    exception and abort these steps. [RFC2616]

 2. (If the given method is not supported for security reasons the user
    agent should raise a SECURITY_ERR exception and abort these steps.)

 3. (Let stored method be method.)

 4. must uppercase GET, POST, HEAD, PUT, DELETE and OPTIONS

 5. (Drop the fragment identifier (if any) from url and let stored url be
    the result of that operation.)

 6. If stored url is a relative reference it must be resolved using the
    current value of the baseURI attribute of the Document object currently
    associated with the Window pointer.

    If this fails the user agent must raise a SYNTAX_ERR exception and
    abort these steps.

 7. If the "user:password" format in the userinfo production defined in
    section 3.2.1 of RFC 3986 is not supported for the relevant scheme and
    stored url contains this format the user agent must throw a SYNTAX_ERR
    and abort these steps. [RFC3986]

 8. (If stored url contains the "user:password" format let stored user be
    the user part and stored password be the password part.)

 9. (If stored url just contains the "user" format let stored user be the
    user part.)

10. (If stored url is non same-origin the user agent should raise a
    SECURITY_ERR exception and abort these steps.)

11. (Let async be the value of the async argument or false if it was
    omitted.)

12. If the user argument was not omitted and its syntax does not match
    that specified by the relevant authentication scheme the user agent
    must raise a SYNTAX_ERR exception and abort these steps.

13. (If the user argument was not omitted and is not null let stored user
    be user encoded using the encoding specified in the relevant
    authentication scheme or UTF-8 if the scheme fails to specify an
    encoding.)

14. (If the user argument was not omitted and is null remove stored user.)

15. If the password argument was not omitted and its syntax does not match
    that specified by the relevant authentication scheme the user agent
    must raise a SYNTAX_ERR exception and abort these steps.

16. If the password argument was not omitted and is not null let stored
    password be password encoded using the encoding specified in the
    relevant authentication scheme or UTF-8 if the scheme fails to specify
    an encoding.

17. (If the password argument was not omitted and is null remove stored
    password.)

18. (Set responseText, responseXML, status and statusText to their initial
    values and reset the list of request headers.)

19. (Any network activity for which the object responsible should be
    cancelled.)

20. Switch the object to the OPEN state; the user agent must then
    synchronously dispatch a readystatechange event on the object and abort
    these steps (returning the method call).


when setRequestHeader(header, value) is invoked, the user agent must
follow the following steps:

 1. If the state of the object is not OPEN the user agent must raise an
    INVALID_STATE_ERR exception and abort these steps.

 2. If the send() flag is set the user agent must raise an
    INVALID_STATE_ERR exception and abort these steps.

 3. If the header argument doesn't match the field-name production as
    defined by section 4.2 of RFC 2616 or is null the user agent must raise
    a SYNTAX_ERR and abort these steps. [RFC2616]

 4. If the value argument is null the user agent must abort these steps.
    (Don't raise an exception.)

 5. If the value argument doesn't match the field-value production as
    defined by section 4.2 of RFC 2616 the user agent must raise a SYNTAX_ERR
    and abort these steps. [RFC2616]

 6. (For security reasons these steps should be aborted if the header
    argument case-insensitively matches one of the following headers: ...)

 7. If the header argument is not in the list of request headers the user
    agent must append the header with its associated value to the list and
    abort these steps.

 8. If the header argument is in the list of request headers the user
    agent must either use multiple headers, combine the values or use a
    combination of those (section 4.2, RFC 2616). [RFC2616]

The list of request headers must be reset when the open() method is
invoked.


When send(data) is invoked, the user agent must follow the following steps:

 1. If the state of the object is not OPEN the user agent must raise an
    INVALID_STATE_ERR exception and abort these steps.

 2. If the send() flag is set the user agent must raise an
    INVALID_STATE_ERR exception and abort these steps.

 3. If the data argument has not been omitted and is not null it must be
    used for the entity body as defined by section 7.2 of RFC 2616.
    [RFC2616].

       if data is a DOMString:
          data must be encoded as UTF-8 for transmission.

       if data is a Document:
          data must be serialized into a namespace well-formed XML
          document and encoded using the encoding given by
          data.xmlEncoding, if specified, or UTF-8 otherwise. If this fails
          because the Document cannot be serialized the user agent must act
          as if data was null.

          If no Content-Type header has been set by the script the user
          agent must set append it to the list of request headers with a
          value of application/xml.

       else:
          The stringification mechanisms of the host language must be used
          on data and the result must be treated as if data is a DOMString.

    If the data argument has been omitted or is null no entity body must
    be used in the request.

 4. (Make a request to stored url using stored method, stored user (if
    provided) and stored password (if provided) taking into account the
    entity body, list of request headers and the rules listed directly
    after this set of steps.)

 5. The user agent must then synchronously dispatch a readystatechange
    event on the object.

 6. If async is true the user agent must set the send() flag, directly
    unset it when the state changes and return the send() method call.

 7. (If the request has been successfully acknowledged switch the state to
    SENT)

    the user agent must then synchronously dispatch a readystatechange
    event on the object.

 8. (If all HTTP headers have been receieved, immediately before receiving
    the message body (if any), switch the state to RECEIVING)

    the user agent must then synchronously dispatch a readystatechange
    event on the object.

 9. If the response is an HTTP redirect (status code 301, 302, 303 or
    307), then it must be transparently followed (unless it violates
    security, infinite loop precautions or the scheme isn't supported).

10. If something goes wrong (infinite loop, network errors) the user agent
    must follow the following set of steps:

     1. (Set responseText, responseXML, status and statusText to their
        initial values and reset the list of request headers.)

     2. (Switch the state to LOADED.)

     3. If async is set to false the user agent must raise a NETWORK_ERR
        exception. (Don't abort these steps.)

     4. (Synchronously dispatch a readystatechange event on the object.)

     5. (Abort the overall algorithm.)

11. (When the request has successfully completed loading, switch the state
    to LOADED)

    the user agent must then synchronously dispatch a readystatechange
    event on the object and abort these steps (and return the method call
    in case of async being false).

(If the user agent allows the specification of a proxy it should modify
the request appropriately; i.e., connect to the proxy host instead of the
origin server, modify the Request-Line and send Proxy-Authorization
headers as specified.)

(If the user agent supports HTTP Authentication it should consider
requests originating from this object to be part of the protection space
that includes the accessed URIs and send Authorization headers and handle
401 Unauthorised requests appropriately.)

(if authentication fails, user agents should prompt the users for
credentials. [RFC2617])

(If the user agent supports HTTP State Management it should persist,
discard and send cookies (as received in the Set-Cookie and Set-Cookie2
response headers, and sent in the Cookie header) as applicable. [RFC2965])

(If the user agent implements a HTTP cache it should respect Cache-Control
request headers set by the script (e.g., Cache-Control: no-cache bypasses
the cache).)

It must not send Cache-Control or Pragma request headers automatically
unless the user explicitly requests such behaviour (e.g., by
(force-)reloading the page).

304 Not Modified responses that are a result of a user agent generated
conditional request must be presented as 200 OK responses with the
appropriate content.

The user agent must allow scripts to override automatic cache validation
by setting request headers (e.g., If-None-Match, If-Modified-Since),

...in which case 304 Not Modified responses must be passed through.
[RFC2616]

(If the user agent implements server-driven content-negotiation it should
set Accept-Language, Accept-Encoding and Accept-Charset headers as
appropriate;)

...it must not automatically set the Accept header.

Responses to such requests must have the content-codings automatically
decoded. [RFC2616]


when abort() is invoked, the user agent must run the following steps:

 1. (Set the responseText, responseXML, status and responseText attributes
     to their initial value as well as removing any registered request
     headers.)
     
 2. (Any network activity for which the object responsible should be
    cancelled.)

 3. (Switch the state to LOADED;)

    ...the user agent must then synchronously dispatch a readystatechange
    event on the object.

 4. Switch the state to UNINITIALIZED. (Don't dispatch the
    readystatechange event.)


when getAllResponseHeaders() is invoked, the user agent must run the
following steps:

 1. If the state is not RECEIVING or LOADED the user agent must raise an
    INVALID_STATE_ERR exception and abort these steps.

 2. The user agent must return all the HTTP headers, as a single string,
    with each header line separated by a U+000D CR U+000A LF pair excluding
    the status line.


when getResponseHeader(header) is invoked, the user agent must run the
following steps:

 1. If the state is not RECEIVING or LOADED the user agent must raise an
    INVALID_STATE_ERR exception and abort these steps.

 2. If the header argument doesn't match the field-name production the
    user agent must raise a SYNTAX_ERR exception and abort these steps.

 3. If the header argument case-insensitively matches multiple HTTP
    headers for the last request sent the user agent must return the values
    of these headers as a single concatenated string separated from each
    other by an U+OO2C COMMA followed by an U+0020 SPACE and abort these
    steps.

 4. If the header argument case-insensitively matches a single HTTP header
    for the last request sent the user agent must return the value of that
    header and abort these steps.

 5. The method must return null.


(responseText of type DOMString, readonly)

If the state is not RECEIVING or LOADED, the user agent must raise an
INVALID_STATE_ERR exception.

Otherwise, if there's no entity body this attribute must be null.

If there is, it must be the fragment of the entity body received so far
(when the state is RECEIVING) or the complete entity body (when the state
is LOADED), interpreted as a stream of characters.

If the response includes a MIME type understood by the user agent the
characters must be decoded following the relevant MIME type specification.

If the user agent cannot derive a character stream in accord with the
media type specification, responseText must be null.

Its initial value must be the null.


(responseXML of type Document, readonly)

If the state is not LOADED, user agents must raise an INVALID_STATE_ERR
exception.

Otherwise, if there's no entity body this attribute must be null.

If there is, and the Content-Type header contains a media type (ignoring
any parameters) that is either text/xml, application/xml, or ends in +xml,
it must be an object that implements the Document interface representing
the parsed document.

If Content-Type did not contain such a media type, or if the document
could not be parsed (due to an XML namespace well-formedness error or
unsupported character encoding, for instance), it must be null.

Its initial value must be null.


(status of type unsigned short, readonly)

On getting, if available, it must return the HTTP status code sent by the
server (typically 200 for a successful request).

Otherwise, if not available, the user agent must raise an INVALID_STATE_ERR
exception.

(statusText of type DOMString, readonly)

On getting, if available, it must return the HTTP status text sent by the
server (appears after the status code).

Otherwise, if not available, the user agent must raise an INVALID_STATE_ERR
exception.

When the user agent dispatches a readystatechange event (as indicated
above) it must not bubble,

...must not be cancelable

...and must implement the Event interface.

Its namespaceURI attribute must be null.