<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26736</bug_id>
          
          <creation_ts>2014-09-05 13:03:23 +0000</creation_ts>
          <short_desc>Does the final progress event need to be dispatched after readystatechange?</short_desc>
          <delta_ts>2016-08-12 08:45:43 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>XHR</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Takeshi Yoshino">tyoshino</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>bugs</cc>
    
    <cc>glenn</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>111062</commentid>
    <comment_count>0</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2014-09-05 13:03:23 +0000</bug_when>
    <thetext>Related to bug25587 but about successful case.

http://xhr.spec.whatwg.org/#handle-response-end-of-file

It&apos;s specified that XHR must fire the final progress event after readystatechange.

Anne&apos;s comment about this change is here: http://lists.w3.org/Archives/Public/public-webapps/2011OctDec/1712.html

Anne, what you had to do is to dispatch a progress event with loaded and total at the point we received all data. It&apos;s ok that the final progress event is dispatched before readystatechange dispatch as long as its loaded and total represent all data. Right?

Commits:
- https://dvcs.w3.org/hg/xhr/rev/5c90cb13ad25
- https://github.com/whatwg/xhr/commit/f1c744d6cb74371bbbaa4c07f17bfa9e9caa1718

FYI, here&apos;s the result of event order checking for Chrome, Firefox and IE.
https://code.google.com/p/chromium/issues/detail?id=409544#c1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111071</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-09-05 15:34:12 +0000</bug_when>
    <thetext>So when progress dispatches, does readyState return 3?

I don&apos;t really feel strongly about what we do here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111091</commentid>
    <comment_count>2</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2014-09-05 18:18:01 +0000</bug_when>
    <thetext>I think it&apos;s fine if the final progress event is fired earlier.  The important thing is that a &quot;100% complete&quot; progress event is always sent.

If it&apos;s fired before readystatechange, it should be before state is set to DONE, so we don&apos;t have an event between the state change and the readystatechange event.

I think I&apos;d put it after step 3 (&quot;If response is a network error...&quot;).  That way, setting the final response body (step 4) and switching to DONE (step 5) are still atomic to scripts, there are still no events between DONE and readystatechange, and this progress event happens in the same state as the other ones.  It&apos;s just a last-minute progress event before any of the real end of file state changes start to happen.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111099</commentid>
    <comment_count>3</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-09-05 20:03:30 +0000</bug_when>
    <thetext>I don&apos;t have strong feeling here.
In my mind readyState property and readystatechange event are legacy, 
almost deprecated, and one should just use loadstart/progress/load/etc events always.

But I agree with Glenn.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111101</commentid>
    <comment_count>4</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2014-09-05 20:35:20 +0000</bug_when>
    <thetext>It&apos;s minor, but doing it this way should make it easier to avoid sending a redundant &quot;complete&quot; progress notification.  If you already sent a 100% progress notification during the transfer, we&apos;re requiring that you send another one, since this one has to be after readystatechange.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111126</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-09-06 09:49:02 +0000</bug_when>
    <thetext>Glenn, it would still be observable if it&apos;s same task or not same task. If we want same task, doing it as it is now seems the most sane.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111129</commentid>
    <comment_count>6</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2014-09-06 16:50:08 +0000</bug_when>
    <thetext>If what&apos;s in the same task as what?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111130</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-09-06 17:02:40 +0000</bug_when>
    <thetext>The progress event and the readyState change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111135</commentid>
    <comment_count>8</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2014-09-07 04:43:09 +0000</bug_when>
    <thetext>(In reply to Anne from comment #7)
&gt; The progress event and the readyState change.

Not sure if that matters, though I guess it makes that simplification (&quot;if the transfer already sent onprogress 100%, you don&apos;t have to send it again here&quot;) not work, since that message wouldn&apos;t be in the same task as this.  (I guess another way implementations could avoid the duplicate onprogress would be to just not send onprogress during the transfer if loaded &lt; total, so this is the only one that gets sent, at least if the length is known.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122255</commentid>
    <comment_count>9</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2015-07-22 07:54:00 +0000</bug_when>
    <thetext>100% event is always notified also by the &quot;load&quot; progress event.

To always dispatch &quot;100%&quot; as &quot;progress&quot; progress event would benefit users who want to show progress bar by only setting up the onprogress handler. But leads to duplicate events for notification of the equivalent phenomenon.

I&apos;m leaning toward skipping the final &quot;progress&quot; progress event and just delivering the &quot;load&quot; progress event.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122261</commentid>
    <comment_count>10</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2015-07-22 13:53:07 +0000</bug_when>
    <thetext>It&apos;s normal for multiple events to be fired for a single thing happening.  Avoiding that isn&apos;t a goal--avoiding inconsistent behavior in websites because of confusing, unobvious API behavior (no 100% progress event being fired even though the task did complete) is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127128</commentid>
    <comment_count>11</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2016-08-12 08:45:43 +0000</bug_when>
    <thetext>If this is still not what everyone wants, let&apos;s discuss it on GitHub.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>