Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

e2e: the video button comes back in an open tab once the host can be reached, and reaches a restarted MDM (#474) (#886)

Ahmed Nefzaoui69a7d0f9ae6e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index caf21874..cbd88c16 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -80,7 +80,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
- **Download video** without ffmpeg (on macOS and Linux, where MDM doesn't install it): the sound alone comes from a format the site sends as one file when it has one, and a sound or video that came as an HLS stream's pieces is saved as what it is (`.aac`, `.ts`) instead of `.mp4`, which players refused to open ([#569](https://github.com/anefzaoui/misterdownloadmanager/issues/569)).
- A freeze when the disk was slow: MDM looked on the disk for a portable data folder on every tick of the window; it now works the data folder out once ([#565](https://github.com/anefzaoui/misterdownloadmanager/issues/565)).
- macOS 15 and later: Chinese names and text find the PingFang font again, which moved into the system's font assets, with Hiragino Sans GB and STHeiti as fallbacks ([#541](https://github.com/anefzaoui/misterdownloadmanager/issues/541)).
-- The video button follows **Options → General → Customize MDM Download panels in browsers** in the pages already open: switched off, or its site listed, it goes within a few seconds, without reloading the page (it stayed until a reload, and on YouTube, which never reloads, for good). A site listed as `example.com` now takes `www.example.com` and its other subdomains too, and a player embedded from another site follows the site in the address bar ([#532](https://github.com/anefzaoui/misterdownloadmanager/issues/532)).
+- The video button follows **Options → General → Customize MDM Download panels in browsers** in the pages already open: switched off, or its site listed, it goes within a few seconds, without reloading the page (it stayed until a reload, and on YouTube, which never reloads, for good). The same way, a page opened while the browser couldn't reach MDM (MDM being installed or updated) gets the button within a few seconds once it can, where it stayed off until a reload ([#474](https://github.com/anefzaoui/misterdownloadmanager/issues/474)). A site listed as `example.com` now takes `www.example.com` and its other subdomains too, and a player embedded from another site follows the site in the address bar ([#532](https://github.com/anefzaoui/misterdownloadmanager/issues/532)).
- macOS: file names in Persian, Arabic, Urdu, Hebrew or Armenian show their letters in the download list and windows instead of boxes, whatever the interface language: these scripts now get the font for them that comes with macOS (Arial Unicode), the first time one is needed ([#533](https://github.com/anefzaoui/misterdownloadmanager/issues/533)).
- A download's progress is saved from its first seconds again: since 0.5.2, when the disk was slow to write the resume state as the download started (no data had arrived yet), the first save of its progress waited nine times as long, up to a minute, so a short download cut off by a crash or a power cut in that time started over from the beginning (part of [#518](https://github.com/anefzaoui/misterdownloadmanager/issues/518)).
- macOS: **Download File Info** opens in front of the browser that asked for it ([#484](https://github.com/anefzaoui/misterdownloadmanager/issues/484)).
@@ -97,7 +97,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
- Linux: **View → Dark Mode support** turns dark on window managers such as Hyprland and sway when only GNOME's setting says so (`gsettings set org.gnome.desktop.interface color-scheme prefer-dark`), as it did when a desktop portal answered ([#324](https://github.com/anefzaoui/misterdownloadmanager/issues/324)).
- Dark mode no longer draws a bright white line under the menu bar, across the whole window, in the Classic and Native themes ([#379](https://github.com/anefzaoui/misterdownloadmanager/issues/379)).
- Windows: a download's progress window with a title of 256 characters or more (a torrent with a long name, or a file name kept whole in a folder too deep to shorten it) has MDM's own title bar again, instead of the system's drawn above it (part of [#540](https://github.com/anefzaoui/misterdownloadmanager/issues/540)).
-- Windows: closing the window hides MDM in the notification area again, as it did before 0.5.2, instead of leaving it minimized in the taskbar with its icon right there, among the hidden icons behind ^ (where Windows puts a new icon). Before hiding the window, MDM asked Windows where the icon was, and Windows 10 and some Windows 11 versions give an icon behind ^ no place; MDM took that for no icon at all. It now also asks whether Windows has the icon, wherever it shows it, and keeps the window in the taskbar only when Windows says it has none (Explorer isn't running, or the icon was lost): when Windows doesn't answer, the window hides as usual, and starting MDM again always brings it back. The same goes for **Minimize to the notification area**, and for a start with Windows, which no longer shows the window minimized after half a minute ([#750](https://github.com/anefzaoui/misterdownloadmanager/issues/750), [#718](https://github.com/anefzaoui/misterdownloadmanager/issues/718), [#754](https://github.com/anefzaoui/misterdownloadmanager/issues/754), [#545](https://github.com/anefzaoui/misterdownloadmanager/issues/545), [#534](https://github.com/anefzaoui/misterdownloadmanager/issues/534), [#527](https://github.com/anefzaoui/misterdownloadmanager/issues/527)).
+- Windows: closing the window hides MDM in the notification area again, as it did before 0.5.2, instead of leaving it minimized in the taskbar with its icon right there, among the hidden icons behind ^ (where Windows puts a new icon). Before hiding the window, MDM asked Windows where the icon was, and Windows 10 and some Windows 11 versions give an icon behind ^ no place; MDM took that for no icon at all. It now also asks whether Windows has the icon, wherever it shows it, and keeps the window in the taskbar only when Windows says it has none (Explorer isn't running, or the icon was lost): when Windows doesn't answer, the window hides as usual, and starting MDM again always brings it back. The same goes for **Minimize to the notification area**, and for a start with Windows, which no longer shows the window minimized after half a minute ([#750](https://github.com/anefzaoui/misterdownloadmanager/issues/750), [#718](https://github.com/anefzaoui/misterdownloadmanager/issues/718), [#754](https://github.com/anefzaoui/misterdownloadmanager/issues/754), [#545](https://github.com/anefzaoui/misterdownloadmanager/issues/545), [#534](https://github.com/anefzaoui/misterdownloadmanager/issues/534), [#527](https://github.com/anefzaoui/misterdownloadmanager/issues/527), [#590](https://github.com/anefzaoui/misterdownloadmanager/issues/590), [#779](https://github.com/anefzaoui/misterdownloadmanager/issues/779)).
- Windows: the window no longer freezes while Explorer is slow to answer about MDM's notification-area icon ("freeze in misterdownloadmanager::tray::Tray::visible_now"). The window asked Explorer about the icon every second, and set the icon's tip, on its own thread, and waited as long as Explorer took: 8 seconds in the report. Both now happen beside the window, which goes by Windows' last answer; an answer that is late or missing is never taken for "no icon", so a window in the notification area stays there ([#747](https://github.com/anefzaoui/misterdownloadmanager/issues/747); thanks to [@TG-Twilight](https://github.com/TG-Twilight) for the first version, [#697](https://github.com/anefzaoui/misterdownloadmanager/pull/697)).
- The browser's **video button** over YouTube's thumbnail previews keeps one place, so it can be clicked: it moved to another corner when the preview showed its sound and captions buttons, back when they hid as the pointer reached it, and away again, and it followed the preview as it shrank. Over the same video it now only moves on to a free corner, never back, and it stays put while the pointer is on it ([#560](https://github.com/anefzaoui/misterdownloadmanager/issues/560)).
- Chrome, Edge, Brave and the other Chromium browsers: a download the extension leaves to the browser keeps the name and folder another extension gives it (Save In's folders, or any extension's own download into a folder). The extension's answer for it counted as a name of its own, an empty one, and when the extension was the newest installed it won: the file landed in the Downloads folder, and the browser could warn of a conflict between the two extensions ([#578](https://github.com/anefzaoui/misterdownloadmanager/issues/578)).
diff --git a/ROADMAP.md b/ROADMAP.md
index ecf461d9..bb7d8a1c 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -810,7 +810,9 @@ These ship in the next version.
- ✅ macOS 15 and later: Chinese text finds PingFang again, which moved into the system's font assets
([#541](https://github.com/anefzaoui/misterdownloadmanager/issues/541))
- ✅ The video button goes when it is switched off, or its site listed, in Options, in pages already
- open ([#532](https://github.com/anefzaoui/misterdownloadmanager/issues/532))
+ open ([#532](https://github.com/anefzaoui/misterdownloadmanager/issues/532)); and comes in a page
+ opened while the browser couldn't reach MDM once it can, without a reload
+ ([#474](https://github.com/anefzaoui/misterdownloadmanager/issues/474))
- ✅ macOS: Persian and other Arabic-script file names show their letters in the download list, not
boxes ([#533](https://github.com/anefzaoui/misterdownloadmanager/issues/533))
- ✅ A server's refusal page is no longer saved under the document's name and shown as complete,
@@ -834,7 +836,9 @@ These ship in the next version.
[#754](https://github.com/anefzaoui/misterdownloadmanager/issues/754),
[#545](https://github.com/anefzaoui/misterdownloadmanager/issues/545),
[#534](https://github.com/anefzaoui/misterdownloadmanager/issues/534),
- [#527](https://github.com/anefzaoui/misterdownloadmanager/issues/527))
+ [#527](https://github.com/anefzaoui/misterdownloadmanager/issues/527),
+ [#590](https://github.com/anefzaoui/misterdownloadmanager/issues/590),
+ [#779](https://github.com/anefzaoui/misterdownloadmanager/issues/779))
- ✅ The window no longer freezes while Explorer is slow to answer about MDM's notification-area
icon: it is asked beside the window
([#747](https://github.com/anefzaoui/misterdownloadmanager/issues/747))
diff --git a/tools/extension/e2e.mjs b/tools/extension/e2e.mjs
index fd3fe76b..03605a5d 100644
--- a/tools/extension/e2e.mjs
+++ b/tools/extension/e2e.mjs
@@ -36,8 +36,9 @@
// clicked, dragged, kept; "never on the site" in the last browser; the button's clicks go through
// its menu's "Open in…" to the Download video window, as in csp, hls, streams, sniffed and
// inplace), panelOptions (the button follows Options in an open tab: off, on, the site listed;
-// #532), videoFocus (mouse idle/fullscreen and keyboard focus, #480), start (MDM not running: the
-// host starts it),
+// #532), videoFocus (mouse idle/fullscreen and keyboard focus, #480), reconnect (a tab opened while
+// the host couldn't start gets the button once it can, no reload; then MDM started by a click, and
+// reached after it quits and starts again, #474), start (MDM not running: the host starts it),
// remote (Send downloads to → Another MDM, #157: paired from the popup, a link downloaded by a
// headless MDM; E2E_REMOTE_URL for one running elsewhere, such as the Docker image: remoteServer).
//
@@ -2826,6 +2827,85 @@ const CASES = {
return videoButton(t.session, t.last);
},
+ // #474: a tab opened while the browser can't reach MDM's host (MDM being installed or updated,
+ // the host failing to start) gets the video button within seconds once the host is back, with
+ // no reload; its click then starts MDM, and after MDM quits and starts again under the open
+ // tab a click still reaches it. The host's program is moved away while the page loads (the
+ // browser can't start it), then put back.
+ async reconnect(t) {
+ const s = t.session;
+ const nmhost = exe("misterdownloadmanager-nmhost");
+ const away = `${nmhost}.e2e-away`;
+ const page = `${LAB}/page?video=${encodeURIComponent("/gen/1M/clip.mp4")}`;
+ const clip = `${LAB}/gen/1M/clip.mp4`;
+ const status = async () => {
+ const popup = await s.tab(`${s.base}popup.html`);
+ try {
+ // The popup's page may still be loading: asked again until it answers.
+ const said = await until("the extension's status", 10000, () =>
+ popup.evaluate(`(globalThis.browser ?? chrome).storage.local.get({ status: { why: null } }).then((v) => JSON.stringify(v.status.why))`).catch(() => ""),
+ );
+ return JSON.parse(said);
+ } finally {
+ await popup.close();
+ }
+ };
+ const click = async (v, label) => {
+ const b = await hover(s, v);
+ if (!b) throw new Error(`${label}: no button over the video`);
+ await s.mouse(await mainPart(s, b), (b.t + b.b) / 2, "click");
+ };
+ const done = [];
+ await stopApp();
+ try {
+ fs.renameSync(nmhost, away);
+ await s.navigate(page);
+ const v = await rect(s, "#video");
+ if (await hover(s, v)) throw new Error("the host can't start: a button showed all the same");
+ const why = await status();
+ if (!why) throw new Error("the host can't start: the toolbar button says connected");
+ done.push(`host away: no button, the toolbar button says ${why}`);
+ fs.renameSync(away, nmhost);
+ // The page asks again (video.js ASK_MS), with no reload.
+ await s.mouse(5, 5);
+ await sleep(PANEL_KEPT_MS);
+ if (!(await hover(s, v))) throw new Error("the host back: no button in the open tab without a reload");
+ done.push("host back: the button in the open tab, no reload");
+ // MDM isn't running: the click starts it, which takes the video. (Its earlier copy of the
+ // file first off its list: a duplicate would be asked about.)
+ await startApp();
+ const earlier = (await mdmList()).filter((d) => d.url === clip).map((d) => d.id);
+ if (earlier.length) await ipc({ action: "delete", ids: earlier });
+ await stopApp();
+ await click(v, "MDM not running");
+ const first = await until("the video's file in MDM's list (MDM started by the host)", 45000, async () =>
+ (await mdmList().catch(() => [])).find((d) => d.url === clip),
+ );
+ if (ourApps().length !== 1) throw new Error(`${ourApps().length} instances run after the click`);
+ const said = await status();
+ if (said && said !== "update-app") throw new Error(`MDM reached, the toolbar button still says ${said}`);
+ done.push(`click: MDM started, ${first.file} in its list, the toolbar button connected`);
+ // MDM quits and starts again under the open tab: the next click reaches the new one.
+ await ipc({ action: "delete", ids: [first.id] });
+ await stopApp();
+ await startApp();
+ const before = new Set((await mdmList()).map((d) => d.id));
+ // The first click's green "Added to MDM" over (6 s): a click on it isn't a new one.
+ await s.mouse(5, 5);
+ await until("the first click's state over", 10000, async () => (await s.pill(PILL_STATE).catch(() => null))?.state !== "sent");
+ await click(v, "MDM started again");
+ const again = await until("the video's file in the restarted MDM's list", 15000, async () => (await mdmList()).find((d) => !before.has(d.id))).catch(async (e) => {
+ throw new Error(`${e.message} (the button: ${JSON.stringify(await s.pill(PILL_STATE))})`);
+ });
+ if (again.url !== clip) throw new Error(`MDM downloads ${again.url}`);
+ done.push(`MDM quit and started again: the next click reached it (${again.file})`);
+ } finally {
+ if (fs.existsSync(away)) fs.renameSync(away, nmhost);
+ await s.mouse(5, 5);
+ }
+ return done.join("; ");
+ },
+
// MDM not running: the host starts it (off the screens, with the test's data folder: both
// reach it through the browser's environment) and hands the download over.
async start(t) {