1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-27 11:22:06 +02:00

expose correct dispose method

testcase for correct dispose method
This commit is contained in:
Alex Vasilenko 2013-03-05 23:23:01 +02:00
parent 2de8ad6f63
commit 1bceadf094
3 changed files with 41 additions and 1 deletions

View File

@ -34,7 +34,7 @@ goog.exportSymbol('videojs.options', vjs.options);
goog.exportSymbol('videojs.cache', vjs.cache);
goog.exportSymbol('videojs.Component', vjs.Component);
goog.exportProperty(vjs.Component.prototype, 'dispose', vjs.Component.prototype.dispose);
//goog.exportProperty(vjs.Component.prototype, 'dispose', vjs.Component.prototype.dispose);
goog.exportProperty(vjs.Component.prototype, 'createEl', vjs.Component.prototype.createEl);
goog.exportProperty(vjs.Component.prototype, 'el', vjs.Component.prototype.el);
goog.exportProperty(vjs.Component.prototype, 'addChild', vjs.Component.prototype.addChild);
@ -51,6 +51,7 @@ goog.exportProperty(vjs.Component.prototype, 'dimensions', vjs.Component.prototy
goog.exportProperty(vjs.Component.prototype, 'ready', vjs.Component.prototype.ready);
goog.exportSymbol('videojs.Player', vjs.Player);
goog.exportProperty(vjs.Player.prototype, 'dispose', vjs.Player.prototype.dispose);
goog.exportSymbol('videojs.MediaLoader', vjs.MediaLoader);
goog.exportSymbol('videojs.PosterImage', vjs.PosterImage);

View File

@ -19,3 +19,21 @@ test('should export ready api call to public', function() {
ok(player.ready !== undefined, 'ready callback is defined');
player.dispose();
});
test('should be able to initialize player twice on the same tag using string reference', function() {
var videoTag = PlayerTest.makeTag();
var id = videoTag.id;
var fixture = document.getElementById('qunit-fixture');
fixture.appendChild(videoTag);
var player = _V_('example_1');
player.dispose();
ok(!document.getElementById(id), 'element is removed');
videoTag = PlayerTest.makeTag();
fixture.appendChild(videoTag);
player = _V_('example_1');
player.dispose();
});

View File

@ -212,3 +212,24 @@ test('should not play if firstplay event prevents default', function(){
player.dispose();
});
test('should be able to initialize player twice on the same tag using string reference', function() {
var videoTag = PlayerTest.makeTag();
var id = videoTag.id;
var fixture = document.getElementById('qunit-fixture');
fixture.appendChild(videoTag);
var player = vjs(videoTag.id);
ok(player, 'player is created');
player.dispose();
ok(!document.getElementById(id), 'element is removed');
videoTag = PlayerTest.makeTag();
fixture.appendChild(videoTag);
//here we receive cached version instead of real
player = vjs(videoTag.id);
//here it triggers error, because player was destroyed already after first dispose
player.dispose();
});