Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(error): chromium reset mediaError when the poster is invalid #8410

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});