Skip to content
New issue

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

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

Already on GitHub? # to your account

Errors fixes #2850

Closed
wants to merge 4 commits into from
Closed
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
7 changes: 4 additions & 3 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,7 @@ class Player extends Component {
if (err === null) {
this.error_ = err;
this.removeClass('vjs-error');
this.errorDisplay.close();
return this;
}

Expand All @@ -2117,16 +2118,16 @@ class Player extends Component {
this.error_ = new MediaError(err);
}

// fire an error event on the player
this.trigger('error');

// add the vjs-error classname to the player
this.addClass('vjs-error');

// log the name of the error type and any message
// ie8 just logs "[object object]" if you just log the error object
log.error(`(CODE:${this.error_.code} ${MediaError.errorTypes[this.error_.code]})`, this.error_.message, this.error_);

// fire an error event on the player
this.trigger('error');

return this;
}

Expand Down
88 changes: 18 additions & 70 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,6 @@ q.module('Player', {
}
});

// Compiler doesn't like using 'this' in setup/teardown.
// module("Player", {
// /**
// * @this {*}
// */
// setup: function(){
// window.player1 = true; // using window works
// },

// /**
// * @this {*}
// */
// teardown: function(){
// // if (this.player && this.player.el() !== null) {
// // this.player.dispose();
// // this.player = null;
// // }
// }
// });

// Object.size = function(obj) {
// var size = 0, key;
// for (key in obj) {
// console.log('key', key)
// if (obj.hasOwnProperty(key)) size++;
// }
// return size;
// };


test('should create player instance that inherits from component and dispose it', function(){
var player = TestHelpers.makePlayer();

Expand Down Expand Up @@ -339,24 +309,6 @@ test('should set controls and trigger events', function() {
player.dispose();
});

// Can't figure out how to test fullscreen events with tests
// Browsers aren't triggering the events at least
// asyncTest('should trigger the fullscreenchange event', function() {
// expect(3);

// var player = TestHelpers.makePlayer();
// player.on('fullscreenchange', function(){
// ok(true, 'fullscreenchange event fired');
// ok(this.isFullscreen() === true, 'isFullscreen is true');
// ok(this.el().className.indexOf('vjs-fullscreen') !== -1, 'vjs-fullscreen class added');

// player.dispose();
// start();
// });

// player.requestFullscreen();
// });

test('should toggle user the user state between active and inactive', function(){
var player = TestHelpers.makePlayer({});

Expand Down Expand Up @@ -456,28 +408,6 @@ test('make sure that controls listeners do not get added too many times', functi
player.dispose();
});

// test('should use custom message when encountering an unsupported video type',
// function() {
// videojs.options['notSupportedMessage'] = 'Video no go <a href="">link</a>';
// var fixture = document.getElementById('qunit-fixture');

// var html =
// '<video id="example_1">' +
// '<source src="fake.foo" type="video/foo">' +
// '</video>';

// fixture.innerHTML += html;

// var tag = document.getElementById('example_1');
// var player = new Player(tag, { techOrder: ['techFaker'] });

// var incompatibilityMessage = player.el().getElementsByTagName('p')[0];
// // ie8 capitalizes tag names
// equal(incompatibilityMessage.innerHTML.toLowerCase(), 'video no go <a href="">link</a>');

// player.dispose();
// });

test('should register players with generated ids', function(){
var fixture, video, player, id;
fixture = document.getElementById('qunit-fixture');
Expand Down Expand Up @@ -874,3 +804,21 @@ test('createModal() options object', function() {
strictEqual(modal.options_.label, 'boo', 'modal options are set properly');
modal.close();
});

test('you can clear error in the error event', function() {
let player = TestHelpers.makePlayer();

sinon.stub(log, 'error');

player.error({code: 4});
ok(player.error(), 'we have an error');
player.error(null);

player.one('error', function() {
player.error(null);
});
player.error({code: 4});
ok(!player.error(), 'we no longer have an error');

log.error.restore();
});