mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-07 10:06:21 +00:00
fix(player): treat runtime timeline as cross-origin ready (#1690)
This commit is contained in:
@@ -12,6 +12,7 @@ const makeCallbacks = (): MessageHandlerCallbacks => ({
|
||||
updateControlsPlaying: vi.fn(),
|
||||
dispatchEvent: vi.fn(),
|
||||
onRuntimeReady: vi.fn(),
|
||||
onRuntimeTimelineReady: vi.fn(),
|
||||
seek: vi.fn(),
|
||||
play: vi.fn(),
|
||||
getLoop: vi.fn(() => false),
|
||||
@@ -101,3 +102,29 @@ describe("handleRuntimeMessage media autoplay fallback", () => {
|
||||
expect(callbacks.sendControl).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("handleRuntimeMessage timeline ready", () => {
|
||||
const timelineEvent = (durationInFrames: unknown, source: object): MessageEvent =>
|
||||
({
|
||||
source,
|
||||
data: { source: "hf-preview", type: "timeline", durationInFrames, scenes: [] },
|
||||
}) as unknown as MessageEvent;
|
||||
|
||||
it("reports a finite positive timeline duration in seconds", () => {
|
||||
const frameWindow = {} as Window;
|
||||
const callbacks = makeCallbacks();
|
||||
|
||||
handleRuntimeMessage(timelineEvent(120, frameWindow), frameWindow, callbacks);
|
||||
|
||||
expect(callbacks.onRuntimeTimelineReady).toHaveBeenCalledWith(4);
|
||||
});
|
||||
|
||||
it("does not report invalid timeline durations as ready", () => {
|
||||
const frameWindow = {} as Window;
|
||||
const callbacks = makeCallbacks();
|
||||
|
||||
handleRuntimeMessage(timelineEvent(Infinity, frameWindow), frameWindow, callbacks);
|
||||
|
||||
expect(callbacks.onRuntimeTimelineReady).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user