@@ -3,8 +3,11 @@ import { mediaElementTime } from "@hyperframes/core/runtime/media-clock";
33import { ParentMediaManager , type ProxyEntry } from "./parent-media" ;
44
55// A fake media element whose paused state is driven by play()/pause() stubs.
6- function makeFakeAudio ( initiallyPaused : boolean ) : HTMLMediaElement {
7- const el = new Audio ( ) ;
6+ function makeFakeAudio (
7+ initiallyPaused : boolean ,
8+ tag : "audio" | "video" = "audio" ,
9+ ) : HTMLMediaElement {
10+ const el = tag === "video" ? document . createElement ( "video" ) : new Audio ( ) ;
811 let paused = initiallyPaused ;
912 Object . defineProperty ( el , "paused" , { get : ( ) => paused } ) ;
1013 el . pause = ( ) => {
@@ -486,9 +489,9 @@ describe("ParentMediaManager drift policy", () => {
486489 } ) ;
487490
488491 // A playing proxy `lag` seconds behind a timeline at `t`, a clip that starts at 0 and plays from media 0.
489- function playingProxy ( lag : number , t = 5 ) {
492+ function playingProxy ( lag : number , t = 5 , tag : "audio" | "video" = "audio" ) {
490493 const mgr = makeManager ( { isPaused : false } ) ;
491- const el = makeFakeAudio ( false ) ;
494+ const el = makeFakeAudio ( false , tag ) ;
492495 const writes : number [ ] = [ ] ;
493496 let time = t - lag ;
494497 Object . defineProperty ( el , "currentTime" , {
@@ -537,6 +540,15 @@ describe("ParentMediaManager drift policy", () => {
537540 expect ( writes [ 0 ] ) . toBeCloseTo ( mediaElementTime ( 5.1 ) , 9 ) ;
538541 } ) ;
539542
543+ it ( "seeks a video proxy that holds a 1 s lag: a proxy is heard, whatever its tag" , ( ) => {
544+ const { mgr, el, writes, setTime } = playingProxy ( 1 , 5 , "video" ) ;
545+ mgr . mirrorTime ( 5 ) ;
546+ setTime ( 4.1 ) ;
547+ mgr . mirrorTime ( 5.1 ) ;
548+ expect ( writes ) . toHaveLength ( 1 ) ;
549+ expect ( el . playbackRate ) . toBe ( 1 ) ;
550+ } ) ;
551+
540552 it ( "steers, never seeks, a proxy whose lag keeps growing because it is stalled" , ( ) => {
541553 const { mgr, el, writes } = playingProxy ( 0.25 ) ;
542554 mgr . mirrorTime ( 5 ) ;
0 commit comments