mirror of
https://github.com/videojs/video.js.git
synced 2025-01-13 10:32:26 +02:00
@gkatsev fixed clearing out errors. closes #2850
This commit is contained in:
parent
552d8cbda3
commit
5f9095079e
@ -2,7 +2,7 @@ CHANGELOG
|
||||
=========
|
||||
|
||||
## HEAD (Unreleased)
|
||||
_(none)_
|
||||
* @gkatsev fixed clearing out errors ([view](https://github.com/videojs/video.js/pull/2850))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -2107,6 +2107,7 @@ class Player extends Component {
|
||||
if (err === null) {
|
||||
this.error_ = err;
|
||||
this.removeClass('vjs-error');
|
||||
this.errorDisplay.close();
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -2117,9 +2118,6 @@ 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');
|
||||
|
||||
@ -2127,6 +2125,9 @@ class Player extends Component {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
@ -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({});
|
||||
|
||||
@ -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');
|
||||
@ -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();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user