[Bug 19470] New: Event firing sequence on abort() after send()

https://www.w3.org/Bugs/Public/show_bug.cgi?id=19470

          Priority: P2
            Bug ID: 19470
                CC: mike@w3.org, public-webapps@w3.org
          Assignee: annevk@annevk.nl
           Summary: Event firing sequence on abort() after send()
        QA Contact: public-webapps-bugzilla@w3.org
          Severity: normal
    Classification: Unclassified
                OS: Linux
          Reporter: dominik.rottsches@intel.com
          Hardware: PC
            Status: NEW
           Version: unspecified
         Component: XHR
           Product: WebAppsWG

Looking at the following simplified test case:

function testAbort()
{
    xhr =  new XMLHttpRequest();
    xhr.onloadstart = <push this event to a stack>;
    xhr.onabort = <push this event to a stack>;
    xhr.onerror = <push this event to a stack>;
    xhr.onload = <push this event to a stack>;
    xhr.onloadend = <push this event to a stack>;
    xhr.onreadystatechange = function(e) {
        if (xhr.readyState == xhr.DONE)
            xhr.abort();
    }
    xhr.open("GET", "get.txt", false);
    xhr.send();
    completeTest(); // <compare stack with expected event sequence>
}

We have a synchronous GET request which is sent out to the network. For the
purpose of this example, let's assume the request completes successfully, then
we will end up at the rule for "Switch to the DONE state."
Citing from "Infrastructure for the send() method"
"When it is said to switch to the DONE state run these steps:
1. If the synchronous flag is set, update the response entity body.
2. Unset the synchronous flag.
3. Change the state to DONE.
4. Fire an event named readystatechange.
5. Fire a progress event named progress.
6. Fire a progress event named load.
7. Fire a progress event named loadend."


So, when executing step 4 "Fire an event named readystatechange" we come to our
example test's line
        if (xhr.readyState == xhr.DONE)
            xhr.abort();
So, we call abort() downstream from the callback in step 4.

Then, 4.7.8 The abort() method says in step 1:
1. Terminate the send() algorithm.

This rule would strictly speaking abort steps 5 to 7. No more progress, load
and loadend callbacks after abort(). Note: No abort event itself would be send
either, since we're in DONE state.

Current behavior in WebKit is: after readystatechange: abort, loadend (which I
am planning to change to "no events dispatched at all")
IE9: no events dispatched after readystatechange.
FF: After readystatechange: Load, loadend (no abort).

I don't have a fix suggestion yet, first I'd like to hear editors' feedback
whether you see an issue here as well.

What is the intention of the spec - should those step 5-7 events be fired in
any case?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Thursday, 11 October 2012 13:12:31 UTC