test: cover the popup blacklist UI, tighten audit findings

The delta model was only covered at module level; the popup wiring around
it was not exercised at all. Seven specs now drive the real settings UI in
the packed extension, including the migration path: a pre-v3.1.0 snapshot
is converted on open, the legacy key is removed, and a default missing
from that snapshot is delivered again.

Also from the audit pass:
- await the blacklist read in init instead of firing a floating promise
- unify the debug report on the finder's own candidate list, which the
  separate traversal missed shadow-DOM videos from
- assert that a single candidate is always returned regardless of its
  ranking signals, so no scoring signal can regress a single-player site

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
KoalaDev
2026-08-14 07:39:41 +02:00
parent 36e1291d2c
commit 66971150c7
6 changed files with 265 additions and 48 deletions
+22
View File
@@ -97,6 +97,28 @@ assert.strictEqual(
'findVideo should score Shadow DOM videos together with light DOM videos'
);
// Invariant that protects every already-working single-player site: with one
// candidate the ranking is never consulted, so no signal can turn a page that
// used to sync into "no video found".
const lonelyBadCandidate = makeVideo('lonely', 0, 0, { muted: true, duration: 0 });
lonelyBadCandidate.loop = true;
lonelyBadCandidate.controls = false;
lonelyBadCandidate.offsetWidth = 0;
lonelyBadCandidate.offsetHeight = 0;
const lonelyDocument = {
querySelectorAll(selector) {
if (selector === 'video') return [lonelyBadCandidate];
return [];
}
};
assert.strictEqual(
findVideo(lonelyDocument),
lonelyBadCandidate,
'a single candidate is returned even when every ranking signal is against it'
);
// Same-origin player iframe (jkanime.net): the top document has no <video>,
// the real player lives inside the frame document.
const framedPlayer = makeVideo('framed-player', 1280, 720, { muted: false, duration: 1400 });