@@ -2633,6 +2633,70 @@ QUnit.test(
26332633 }
26342634) ;
26352635
2636+ QUnit . test (
2637+ 'getSeekableRange_ returns a range with an end that is never less than the start' ,
2638+ function ( assert ) {
2639+ const pc = this . playlistController ;
2640+
2641+ const fakeMedia = { } ;
2642+ const fakePlaylistLoader = {
2643+ media ( ) {
2644+ return fakeMedia ;
2645+ }
2646+ } ;
2647+
2648+ // Ensure mainPlaylistLoader_.main is defined (needed by liveEdgeDelay)
2649+ pc . mainPlaylistLoader_ = { main : { } } ;
2650+
2651+ const originalLiveEdgeDelay = Vhs . Playlist . liveEdgeDelay ;
2652+
2653+ // --- Scenario 1: liveEdgeDelay = 0 ---
2654+ // With a reliable sync info of start=10 and end=15, if liveEdgeDelay is 0 then:
2655+ // calculatedEnd = Math.max(10, 15 - 0) = 15
2656+ // Expected seekable range: [10,15]
2657+ Vhs . Playlist . liveEdgeDelay = function ( main , media ) {
2658+ return 0 ;
2659+ } ;
2660+
2661+ pc . syncController_ . getMediaSequenceSync = function ( type ) {
2662+ if ( type === 'main' ) {
2663+ return {
2664+ isReliable : true ,
2665+ start : 10 ,
2666+ end : 15
2667+ } ;
2668+ }
2669+ return null ;
2670+ } ;
2671+
2672+ let seekable = pc . getSeekableRange_ ( fakePlaylistLoader , 'main' ) ;
2673+
2674+ timeRangesEqual (
2675+ seekable ,
2676+ createTimeRanges ( [ [ 10 , 15 ] ] ) ,
2677+ 'With liveEdgeDelay 0, seekable range is [10,15]'
2678+ ) ;
2679+
2680+ // --- Scenario 2: liveEdgeDelay large enough to force clamping ---
2681+ // With the same sync info (start=10, end=15), if liveEdgeDelay = 10 then:
2682+ // calculatedEnd = Math.max(10, 15 - 10) = Math.max(10, 5) = 10
2683+ // Expected seekable range: [10,10] (the end is clamped to start)
2684+ Vhs . Playlist . liveEdgeDelay = function ( main , media ) {
2685+ return 10 ;
2686+ } ;
2687+
2688+ seekable = pc . getSeekableRange_ ( fakePlaylistLoader , 'main' ) ;
2689+
2690+ timeRangesEqual (
2691+ seekable ,
2692+ createTimeRanges ( [ [ 10 , 10 ] ] ) ,
2693+ 'When liveEdgeDelay forces a negative delta, seekable range is clamped to [10,10]'
2694+ ) ;
2695+
2696+ Vhs . Playlist . liveEdgeDelay = originalLiveEdgeDelay ;
2697+ }
2698+ ) ;
2699+
26362700QUnit . test (
26372701 'syncInfoUpdate triggers seekablechanged when seekable is updated' ,
26382702 function ( assert ) {
0 commit comments