Re: [whatwg/xhr] Do not fire upload progress events if the upload complete flag is set (#242)

shannonbooth left a comment (whatwg/xhr#242)

I originally (incorrectly) interpreted browser behaviour as returning if the flag was set, basically:

```diff
diff --git a/xhr.bs b/xhr.bs
index e57f5f8..3b3c945 100644
--- a/xhr.bs
+++ b/xhr.bs
@@ -822,6 +822,8 @@ <h4 id=the-send()-method>The <code>send()</code> method</h4>
     <p>Let <var>processRequestBodyChunkLength</var>, given a <var>bytesLength</var>, be these steps:
 
     <ol>
+     <li><p>If <a>this</a>'s <a>upload complete</a> is true, then return.
+
      <li><p>Increase <var>requestBodyTransmitted</var> by <var>bytesLength</var>.
 
      <li><p>If not roughly 50ms have passed since these steps were last invoked, then return.
@@ -829,7 +831,6 @@ <h4 id=the-send()-method>The <code>send()</code> method</h4>
      <li><p>If <a>this</a>'s <a>upload listener</a> is true, then <a>fire a progress event</a>
      named <a event><code>progress</code></a> at <a>this</a>'s <a>upload object</a> with
      <var>requestBodyTransmitted</var> and <var>requestBodyLength</var>.
-     <!-- upload complete can never be true here I hope -->
     </ol>
 
     <p class=note>These steps are only invoked when new bytes are transmitted.
@@ -838,6 +839,8 @@ <h4 id=the-send()-method>The <code>send()</code> method</h4>
     <p>Let <var>processRequestEndOfBody</var> be these steps:
 
     <ol>
+     <li><p>If <a>this</a>'s <a>upload complete</a> is true, then return.
+
      <li><p>Set <a>this</a>'s <a>upload complete</a> to true.
 
      <li><p>If <a>this</a>'s <a>upload listener</a> is false, then return.
@@ -851,7 +854,6 @@ <h4 id=the-send()-method>The <code>send()</code> method</h4>
      <li><p><a>Fire a progress event</a> named <a event><code>loadend</code></a> at <a>this</a>'s
      <a>upload object</a> with <var>requestBodyTransmitted</var> and <var>requestBodyLength</var>.
     </ol>
-    <!-- upload complete can never be true here I hope -->
 
    <li>
     <p>Let <var>processResponse</var>, given a <var>response</var>, be these steps:
```

This matches the tests:
 * https://github.com/web-platform-tests/wpt/blob/master/xhr/send-redirect-post-upload.htm
 * https://github.com/web-platform-tests/wpt/blob/master/xhr/send-entity-body-get-head-async.htm
 * https://github.com/web-platform-tests/wpt/blob/master/xhr/open-during-abort-processing.htm

But after thinking the implications of such a change through further, I don't think that's desirable, and XHR is missing some test coverage for _when_ the upload is considered complete. I think it should be when the final response arrives, but engines don't seem to have converged on that behaviour. From playing around with some tests locally, Firefox seems to have the behaviour I would expect (not the change I mention above), Chromium and Safari do not. 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/xhr/issues/242#issuecomment-6396472226
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/xhr/issues/242/6396472226@github.com>

Received on Sunday, 25 October 2026 10:25:10 UTC