1
0
mirror of https://github.com/videojs/video.js.git synced 2025-04-09 07:23:57 +02:00

tests: do not throw on tech/player dispose (#5179)

This commit is contained in:
Brandon Casey 2018-05-16 12:02:41 -04:00 committed by GitHub
parent 59c6261cb5
commit 22fd327076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 1 deletions

View File

@ -97,7 +97,9 @@ class ResizeManager extends Component {
dispose() {
if (this.resizeObserver_) {
this.resizeObserver_.unobserve(this.player_.el());
if (this.player_.el()) {
this.resizeObserver_.unobserve(this.player_.el());
}
this.resizeObserver_.disconnect();
}

View File

@ -49,6 +49,48 @@ QUnit.test('dispose should not throw if styleEl is missing', function(assert) {
assert.ok(player.el() === null, 'element disposed');
});
QUnit.test('dispose should not throw if techEl is missing', function(assert) {
const videoTag = TestHelpers.makeTag();
const fixture = document.getElementById('qunit-fixture');
fixture.appendChild(videoTag);
const player = new Player(videoTag);
player.tech_.el_.parentNode.removeChild(player.tech_.el_);
player.tech_.el_ = null;
let error;
try {
player.dispose();
} catch (e) {
error = e;
}
assert.notOk(error, 'Function did not throw an error on dispose');
});
QUnit.test('dispose should not throw if playerEl is missing', function(assert) {
const videoTag = TestHelpers.makeTag();
const fixture = document.getElementById('qunit-fixture');
fixture.appendChild(videoTag);
const player = new Player(videoTag);
player.el_.parentNode.removeChild(player.el_);
player.el_ = null;
let error;
try {
player.dispose();
} catch (e) {
error = e;
}
assert.notOk(error, 'Function did not throw an error on dispose');
});
// technically, all uses of videojs.options should be replaced with
// Player.prototype.options_ in this file and a equivalent test using
// videojs.options should be made in video.test.js. Keeping this here