This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21833 - Under read* chaining during load event loadends should be suppressed
Summary: Under read* chaining during load event loadends should be suppressed
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: File API (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Arun
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-25 22:58 UTC by Arun
Modified: 2013-06-07 18:24 UTC (History)
4 users (show)

See Also:


Attachments

Description Arun 2013-04-25 22:58:55 UTC
In code of the sort:

reader.readAsText(file);

reader.onload = function(){reader.readAsText(file2););

The loadend event should not fire.
Comment 1 Travis Leithead [MSFT] 2013-04-26 18:09:02 UTC
One rationale for this, is that when the chained read is started in the load event, if the loadend event then fires, naïve JavaScript code won't distinguish the loadend event from the previous read from the loadend event of the current read.


We think it's better to not fire loadend in the chaining case, so that JavaScript code won't need to add special case code to ignore the loadend event for the previous read.
Comment 2 Eric Uhrhane 2013-04-26 23:35:01 UTC
Agreed; it'll simplify things.  We should also handle the abort case in the same manner [see the thread starting from http://lists.w3.org/Archives/Public/public-webapps/2012JanMar/0915.html; it matches the conclusion here, I believe].
Comment 3 Arun 2013-05-30 23:37:30 UTC
Solutions here might be:

1. Adding something like a synchronously updated LOADEND counter, maybe with timestamp if absolutely necessary.  This is probably what at least two implementations are doing, per listserv conversation, so the spec. could say something like this.  It would be a "soft counter" not exposed to script, of course.

2. Saying something explicitly in prose during "making progress events" and error steps and abort steps about not firing a loadend if superseded by a new read; e.g. something explicit about whether the read is initiated in onload, onerror, or onabort.  But this is awkward, since it isn't advisable to have a spec. need code analysis to determine when to fire loadend.

3. Make loadend itself fire synchronously, but this deviates from other event models.
Comment 4 Arun 2013-06-06 22:01:28 UTC
In fact, the bug can be fairly easily solved with the existing readyState.  I've made the required changes and would appreciate some review before closing this bug out.

Relevant changes are:

1. "Step 8" of readAsDataURL http://dev.w3.org/2006/webapi/FileAPI/#dfn-readAsDataURL

2. "Step 9" of readAsText http://dev.w3.org/2006/webapi/FileAPI/#dfn-readAsText

3. "Step 9" of readAsArrayBuffer

4. abort() http://dev.w3.org/2006/webapi/FileAPI/#abort

5. error steps http://dev.w3.org/2006/webapi/FileAPI/#dfn-error-steps