From db882cd49db09835d1d4c827427bb475ba4fe6da Mon Sep 17 00:00:00 2001 From: mister-ben Date: Wed, 1 Feb 2023 18:08:30 +0100 Subject: [PATCH] fix: remove unnecessary handling of invalid cues (#7956) --- src/js/tracks/text-track.js | 4 ---- test/unit/tracks/text-track.test.js | 37 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/js/tracks/text-track.js b/src/js/tracks/text-track.js index caf766c32b..c41df8e651 100644 --- a/src/js/tracks/text-track.js +++ b/src/js/tracks/text-track.js @@ -326,10 +326,6 @@ class TextTrack extends Track { if (cue.startTime <= ct && cue.endTime >= ct) { active.push(cue); - } else if (cue.startTime === cue.endTime && - cue.startTime <= ct && - cue.startTime + 0.5 >= ct) { - active.push(cue); } } diff --git a/test/unit/tracks/text-track.test.js b/test/unit/tracks/text-track.test.js index 571e3fc4bf..1cb09a3caa 100644 --- a/test/unit/tracks/text-track.test.js +++ b/test/unit/tracks/text-track.test.js @@ -253,6 +253,43 @@ QUnit.test('can only remove one cue at a time', function(assert) { assert.equal(tt.cues.length, 0, 'we have removed the other instance of cue1'); }); +QUnit.test('does not include past cues in activeCues', function(assert) { + // Testing for the absense of a previous behaviour, which considered cues with equal + // start and end times as active 0.5s after ending + const player = TestHelpers.makePlayer(); + const tt = new TextTrack({ + tech: player.tech_, + mode: 'showing' + }); + const expectedCue = { + id: '2', + startTime: 2.555, + endTime: 3 + }; + + player.tech_.currentTime = function() { + return 2.556; + }; + + tt.addCue({ + id: '1', + startTime: 1, + endTime: 2.555 + }); + tt.addCue({ + id: '2', + startTime: 2.555, + endTime: 2.555 + }); + // start 2.55 + tt.addCue(expectedCue); + + player.tech_.trigger('playing'); + + assert.equal(tt.activeCues_.length, 1, 'only one cue is present'); + assert.equal(tt.activeCues_[0].originalCue_, expectedCue, 'correct active cue is present'); +}); + QUnit.test('does not fire cuechange before Tech is ready', function(assert) { const done = assert.async(); const clock = sinon.useFakeTimers();