Skip to content

Commit

Permalink
fix: remove unnecessary handling of invalid cues (#7956)
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben authored Feb 1, 2023
1 parent 33b476d commit db882cd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/js/tracks/text-track.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
37 changes: 37 additions & 0 deletions test/unit/tracks/text-track.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit db882cd

Please sign in to comment.