Skip to content

A late failure of the last source's player stays its own; one list says who may message the background - #608

Merged
Nawid3333 merged 1 commit into
mainfrom
fix/stale-events-message-senders
Oct 28, 2026
Merged

Nawid3333 merged 1 commit into
mainfrom
fix/stale-events-message-senders

Conversation

@Nawid3333

Copy link
Copy Markdown
Owner

Two small fixes the refactor review of 1.3.82.160 found (no refactor of working code).

1. A failure of the last source's player no longer touches the next source

setSource counts the next source at once, but the last source's player stays this.player until resetPlayer tears it down. What it reported in between was taken for the new source's:

  • its hand-over to Firefox's own player (PLAY_DIRECTLY) played the old URL over the source the user had just picked;
  • its ERROR / NEED_KEY showed the load error over the source on its way in;
  • a refused link of the old source was asked for anew and rebuilt over it (renewSourceLink, also when the answer came after the next source was asked for).

tryNextSource and recoverPlayer already checked fallbacks.request === sourceRequests; every failure route does now (FastStreamClient.isCurrentAttempt, plus the check in renewSourceLink before asking and after the answer).

2. One list says who may send the background each message

runtime.onMessage answers 33 message types. Five checked fromOwnPage(sender) where they were answered; others did not, though only FastStream's own pages send them: LOAD_OPTIONS, MPV_TEST (its answer includes the mpv path), CLEAR_SOURCES, REQUEST_PLAYLIST_NAVIGATION. Web pages cannot message the background, and FastStream's content script never sends these, so this is hardening (a compromised content process), not a page exploit.

MessageSenders now classifies every answered type as 'own' (FastStream's pages only) or 'any' (content scripts too), read before any handler, replacing the five inline checks. backgroundMessages.test.mjs keeps it complete: every answered type is listed, no listed type is stale, and no type a content script sends is 'own'. The background test harness sends an 'own' message from the player page unless a test names another sender.

Tests

  • New: client race tests (each fails on main; the late-link case also fails with only the first check), backgroundMessages.test.mjs, a CLEAR_SOURCES-from-a-page case; removing the gate fails 4 tests.
  • Local: lint, tsc, 3368 unit tests; all 25 extension and 10 classic e2e specs except the mpv ones.
  • reload-keeps-buffer failed in the full parallel e2e run (one segment that was still downloading at the reload was asked for again), and passes alone twice on this branch and twice on main: a timing race of the spec under load, not this change.
  • glm reviewed both halves: no finding.

🤖 Generated with Claude Code

…ys who may message the background

setSource counts the next source at once, and the last source's player stays the player until
resetPlayer tears it down. What it reported in between was taken for the new source's: its
hand-over to Firefox's own player played the old URL over the source the user had just picked,
its error and NEED_KEY showed the load error over it, and a refused link of the old source was
asked for anew and rebuilt over it. tryNextSource and recoverPlayer checked this already; every
failure route does now (FastStreamClient.isCurrentAttempt; renewSourceLink also after the
background's answer).

The background's runtime.onMessage answered 33 message types, and some checked their sender
where they were answered while others did not: LOAD_OPTIONS, MPV_TEST, CLEAR_SOURCES and
REQUEST_PLAYLIST_NAVIGATION, which only the options page or the player send, did what any
content script asked. MessageSenders now says for every type whether FastStream's own pages
only or its content scripts too may send it, read before any handler, in place of the five
inline checks. backgroundMessages.test.mjs keeps it complete: every answered type listed, none
a content script sends marked own-pages-only. The test harness sends an own-pages message from
the player page unless a test names another sender.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Nawid3333
Nawid3333 merged commit cfe2e80 into main Oct 28, 2026
23 checks passed
@Nawid3333
Nawid3333 deleted the fix/stale-events-message-senders branch October 28, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant