mirror of
https://github.com/videojs/video.js.git
synced 2025-01-02 06:32:07 +02:00
fix(error): chromium reset mediaError when the poster is invalid (#8410)
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
This commit is contained in:
parent
781eb436e3
commit
68f1429d9b
@ -2160,7 +2160,9 @@ class Player extends Component {
|
||||
handleTechError_() {
|
||||
const error = this.tech_.error();
|
||||
|
||||
this.error(error);
|
||||
if (error) {
|
||||
this.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user