Well, as mentioned in the comment, it has to be deferred until *after* nsIStreamListener_OnStartRequest is called, because that's when the state is changed on Gecko's XHR (not sure about the others), and that was the most straightforward place for me to add it.
If you call it directly in on_progress, the tests fail. The reason is that Gecko's XHR OnProgress checks the state first to see whether it's uploading or downloading, and because OnStartRequest was not called yet to change the state, it assumes it's an upload progress notification. And so the download progress remains 0.