hls.js emptied the cues of every text track on the element when a manifest loaded or the media attached, our own <track> included, so a VTT that loaded first showed nothing for the session; its subtitle and caption controllers are no longer built. A remounted default <track> was switched to showing by the browser after the hide had run, drawing the cues natively under ours; the hide now follows every added track and mode change.
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
// hls.js empties the cues of every text track on the <video> when a manifest loads or the media
|
|
// attaches — the Plex player's own subtitle <track> included, so a VTT that loaded first showed
|
|
// nothing for the rest of the session. Its subtitle and caption controllers are not built at all.
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
const built: Record<string, unknown>[] = [];
|
|
vi.mock("hls.js", () => {
|
|
class FakeHls {
|
|
static isSupported = () => true;
|
|
static Events = {};
|
|
static ErrorTypes = {};
|
|
constructor(config: Record<string, unknown>) {
|
|
built.push(config);
|
|
}
|
|
on() {}
|
|
}
|
|
return { default: FakeHls };
|
|
});
|
|
|
|
const { createHlsPort } = await import("./hlsPort");
|
|
|
|
describe("createHlsPort", () => {
|
|
it("builds hls.js without the controllers that clear every text track's cues", () => {
|
|
const noop = () => {};
|
|
createHlsPort({
|
|
onManifestParsed: noop,
|
|
onAudioTracksUpdated: noop,
|
|
onFragLoaded: noop,
|
|
onError: noop,
|
|
});
|
|
const config = built[0] ?? {};
|
|
for (const key of [
|
|
"subtitleTrackController",
|
|
"subtitleStreamController",
|
|
"timelineController",
|
|
]) {
|
|
// Set, as undefined: hls.js spreads the config over its defaults, so an absent key keeps them.
|
|
expect(key in config).toBe(true);
|
|
expect(config[key]).toBeUndefined();
|
|
}
|
|
});
|
|
});
|