From 28a20fe02dd63fa6a779b02766b80cc28adadbcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= <14975046+skjnldsv@users.noreply.github.com> Date: Fri, 23 Oct 2026 16:13:08 +0200 Subject: [PATCH] fix(videos): stop offering MPEG and Flash video, which no browser reads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com> --- __tests__/mimeCoverage.spec.ts | 2 -- __tests__/models.spec.ts | 9 +++++++-- lib/models/audios.ts | 4 ++++ lib/models/videos.ts | 9 +++++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/__tests__/mimeCoverage.spec.ts b/__tests__/mimeCoverage.spec.ts index 174cc0c..723c867 100644 --- a/__tests__/mimeCoverage.spec.ts +++ b/__tests__/mimeCoverage.spec.ts @@ -51,8 +51,6 @@ const NOT_COVERED_HERE: Record = { // so a fixture would only record which browser ran the suite 'audio/aacp': 'Chromium reports it cannot play this', 'audio/vorbis': 'not a type any encoder writes; ogg carries vorbis', - 'video/mpeg': 'no engine decodes MPEG-1/2 video', - 'video/x-flv': 'no engine decodes Flash video', 'video/quicktime': 'decoding depends on the codecs inside the container', 'video/x-m4v': 'decoding depends on the codecs inside the container', 'video/x-matroska': 'aliased to webm; decoding depends on the codecs inside', diff --git a/__tests__/models.spec.ts b/__tests__/models.spec.ts index d135af6..37991df 100644 --- a/__tests__/models.spec.ts +++ b/__tests__/models.spec.ts @@ -83,12 +83,10 @@ describe('the custom elements', () => { describe('videos model', () => { it.each([ - 'video/mpeg', 'video/ogg', 'video/webm', 'video/mp4', 'video/x-m4v', - 'video/x-flv', 'video/quicktime', ])('enables browser-supported mime %s', async (mime) => { const { registerVideoHandler } = await import('../lib/models/videos.ts') @@ -97,6 +95,13 @@ describe('videos model', () => { expect(handler.enabled([makeFile({ mime })])).toBe(true) }) + // Neither Chromium nor Firefox reads these: the file downloads instead + it.each(['video/mpeg', 'video/x-flv'])('leaves %s to the download', async (mime) => { + const { registerVideoHandler } = await import('../lib/models/videos.ts') + registerVideoHandler() + expect(handlerById('videos').enabled([makeFile({ mime })])).toBe(false) + }) + it('enables the aliased mime video/x-matroska (maps to video/webm)', async () => { const { registerVideoHandler } = await import('../lib/models/videos.ts') registerVideoHandler() diff --git a/lib/models/audios.ts b/lib/models/audios.ts index 6038383..c2b4923 100644 --- a/lib/models/audios.ts +++ b/lib/models/audios.ts @@ -10,6 +10,10 @@ import { logger } from '../services/logger.ts' import { defineCustomElementOnce } from '../utils/customElements.ts' import { t } from '../utils/l10n.ts' +/** + * Mimes a file can carry, as the server assigns them or a remote storage + * reports them, whose format a browser plays on its own. + */ export const browserSupportedMimes = [ 'audio/aac', 'audio/aacp', diff --git a/lib/models/videos.ts b/lib/models/videos.ts index 6e542c2..7f8ddb3 100644 --- a/lib/models/videos.ts +++ b/lib/models/videos.ts @@ -10,13 +10,18 @@ import { logger } from '../services/logger.ts' import { defineCustomElementOnce } from '../utils/customElements.ts' import { t } from '../utils/l10n.ts' +/** + * Mimes a file can carry, as the server assigns them or a remote storage + * reports them, whose format a browser plays on its own. Not what + * `canPlayType` answers: a QuickTime file holding H.264 plays in Chromium, + * which still says it cannot. MPEG-1/2 (`video/mpeg`) and Flash video + * (`video/x-flv`) are left out, as neither Chromium nor Firefox reads them. + */ export const browserSupportedMimes = [ - 'video/mpeg', 'video/ogg', 'video/webm', 'video/mp4', 'video/x-m4v', - 'video/x-flv', 'video/quicktime', ]