* Call GM.download (promise form). Returns the Promise itself plus the abort handle. * Also collects onprogress events.
(details)
| 475 | * Also collects onprogress events. |
| 476 | */ |
| 477 | function gmDownloadPromise(details) { |
| 478 | const progress = []; |
| 479 | const opts = { |
| 480 | ...details, |
| 481 | onprogress(p) { |
| 482 | progress.push(p); |
| 483 | try { details.onprogress && details.onprogress(p); } catch {} |
| 484 | updateProgress(p.loaded ?? p.done ?? 0, p.total ?? p.totalSize ?? -1); |
| 485 | }, |
| 486 | }; |
| 487 | const ret = GM.download(opts); |
| 488 | return { promise: ret, abort: ret && ret.abort, progress }; |
| 489 | } |
| 490 | |
| 491 | // ---------- The auto test suite ---------- |
| 492 | // Each entry: { name, manual?: boolean, run: async () => void } |
no test coverage detected