Skip to content

Commit

Permalink
fix(error): chromium reset mediaError when the poster is invalid (#8410)
Browse files Browse the repository at this point in the history
When both the media URL and the poster return a response other than 200.
The media error is overwritten by an empty error, leaving the player in an inconsistent state.

- add a condition to `handleTechError_` to ensure that the `error` is truthy
- add a test case

Fixes #8409
  • Loading branch information
amtins authored Sep 27, 2023
1 parent 781eb43 commit 68f1429
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2160,7 +2160,9 @@ class Player extends Component {
handleTechError_() {
const error = this.tech_.error();

this.error(error);
if (error) {
this.error(error);
}
}

/**
Expand Down
34 changes: 34 additions & 0 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3383,3 +3383,37 @@ QUnit.test('crossOrigin value should be maintained after loadMedia is called', f
playerExample2.dispose();
playerExample3.dispose();
});

QUnit.test('should not reset the error when the tech triggers an error that is null', function(assert) {
sinon.stub(log, 'error');

const player = TestHelpers.makePlayer();

player.src({
src: 'http://example.com/movie.unsupported-format',
type: 'video/unsupported-format'
});

this.clock.tick(60);

// Simulates Chromium's behavior when the poster is invalid

// is only there for context, but does nothing
player.poster('invalid');

const spyError = sinon.spy(player, 'error');
// Chromium behavior produced by the video element
const errorStub = sinon.stub(player.tech(true), 'error').callsFake(() => null);

player.tech(true).trigger('error');
// End

assert.ok(player.hasClass('vjs-error'), 'player has vjs-error class');
assert.ok(spyError.notCalled, 'error was not called');
assert.ok(player.error(), 'error is retained');

player.dispose();
spyError.restore();
errorStub.restore();
log.error.restore();
});

0 comments on commit 68f1429

Please sign in to comment.