fix(slideshow): harden media controls in present decks (#1619)

This commit is contained in:
Vance Ingalls
2026-06-20 23:35:58 -07:00
committed by GitHub
parent 0d2198e654
commit 341e65aea2
16 changed files with 1713 additions and 81 deletions
@@ -67,3 +67,37 @@ describe("handleRuntimeMessage stage-size", () => {
expect(callbacks.setCompositionSize).not.toHaveBeenCalled();
});
});
describe("handleRuntimeMessage media autoplay fallback", () => {
const autoplayBlockedEvent = (source: object): MessageEvent =>
({
source,
data: { source: "hf-preview", type: "media-autoplay-blocked" },
}) as unknown as MessageEvent;
it("promotes and mutes iframe output by default", () => {
const frameWindow = {} as Window;
const callbacks = makeCallbacks();
handleRuntimeMessage(autoplayBlockedEvent(frameWindow), frameWindow, callbacks);
expect(callbacks.media.promoteToParentProxy).toHaveBeenCalled();
expect(callbacks.sendControl).toHaveBeenCalledWith("set-media-output-muted", {
muted: true,
});
});
it("does not promote or mute iframe output when the host vetoes the fallback", () => {
const frameWindow = {} as Window;
const callbacks = {
...makeCallbacks(),
shouldPromoteMediaAutoplayFallback: vi.fn(() => false),
};
handleRuntimeMessage(autoplayBlockedEvent(frameWindow), frameWindow, callbacks);
expect(callbacks.shouldPromoteMediaAutoplayFallback).toHaveBeenCalled();
expect(callbacks.media.promoteToParentProxy).not.toHaveBeenCalled();
expect(callbacks.sendControl).not.toHaveBeenCalled();
});
});