/* eslint-env qunit */ import videojs from '../../src/js/video.js'; import window from 'global/window'; import document from 'global/document'; import * as Fn from '../../src/js/utils/fn'; /** * This test is very important for dom-data memory checking * as it runs through a basic player lifecycle for real. */ QUnit.test('create a real player and dispose', function(assert) { assert.timeout(30000); const done = assert.async(); const fixture = document.getElementById('qunit-fixture'); const old = {}; // TODO: remove this code when we have a videojs debug build // see https://github.com/videojs/video.js/issues/5858 old.bind = Fn.bind; Fn.bind = function(context, fn, uid) { const retval = old.bind(context, fn, uid); retval.og_ = fn.og_ || fn; retval.cx_ = fn.cx_ || context; return retval; }; old.throttle = Fn.throttle; Fn.throttle = function(fn, wait) { const retval = old.throttle(fn, wait); retval.og_ = fn.og_ || fn; retval.cx_ = fn.cx_; return retval; }; old.debounce = Fn.debounce; Fn.debounce = function(func, wait, immediate, context = window) { const retval = old.debounce(func, wait, immediate, context); retval.og_ = func.og_ || func; retval.cx_ = func.cx_; return retval; }; // TODO: use a local source rather than a remote one fixture.innerHTML = `

To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video

`.trim(); const player = videojs('vid1', {techOrder: ['html5']}); player.muted(true); player.addTextTrack('captions', 'foo', 'en'); player.ready(function() { assert.ok(player.tech_, 'tech exists'); assert.equal(player.textTracks().length, 1, 'should have one text track'); player.dispose(); Object.keys(old).forEach(function(k) { Fn[k] = old[k]; }); done(); }, true); });