host/downloadjob: Allow pausing downloads in Firefox

Firefox downloads couldn't be paused from Plasma: the job was Killable only, with a TODO saying that "the download job goes away" when suspending on Firefox. The reason: Firefox pauses a download by canceling it and keeping the partial data, so the downloads API reports a paused download as state: "interrupted", error: "USER_CANCELED", paused: true, and the host ended the job on that error. (See get paused(), get state() and get error() in Firefox's toolkit/components/extensions/parent/ext-downloads.js.)

The first commit allows Suspendable for Firefox, ignores USER_CANCELED while the job is suspended, and ends the job when a paused download is canceled (then only paused and canResume change, the state and error stay). Resuming already works: the extension re-sends the download as created.

The second commit fixes what shows after resuming: that re-sent download has 0 bytes received for one update, so the progress dropped to 0 and the fallback speed underflowed (about 4.6 PB/s).

Two separate fixes, so please don't squash.

The second commit also covers !48 (Kai's fix for the speed spike), including Fabian's remaining point there that the progress shouldn't go backwards. If that's preferred, !48 can be closed in favour of this.

Test plan

Tested with the patched host on Plasma 6.7.5 (Fedora 44):

  • Firefox: download a large file, pause and resume it. The job pauses, resumes at the same percentage without a speed spike, and finishes as "Downloaded".
  • Firefox: pause, then cancel in Firefox's downloads panel. The job ends as canceled.
  • Chrome: pause, resume and cancel work as before (Chrome never reported 0 bytes on resume).
  • Replaying the extension's messages into the host while watching org.kde.JobViewV3 covers the same sequences: Firefox pause → resume → complete, Firefox pause → cancel, Chrome pause → resume.

On master it compiles and ctest passes. As a bug fix it might be worth the cherry-pick label for 6.8.

I wrote this with the help of an AI assistant; I tested it and understand the change.

Edited by Simon Hürlimann

Merge request reports

Loading
Loading