From 5151bc597049752efd39af8e6af7df843dff811d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <34163393+amtins@users.noreply.github.com> Date: Wed, 31 May 2023 16:29:35 +0200 Subject: [PATCH] fix(player): techGet is undefined (#8256) Fixes #8255 --- src/js/player.js | 2 +- test/unit/sourceset.test.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/js/player.js b/src/js/player.js index 3cb780ab1c..956bd0aad5 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -1613,7 +1613,7 @@ class Player extends Component { return; } - const techSrc = this.techGet('currentSrc'); + const techSrc = this.techGet_('currentSrc'); this.lastSource_.tech = techSrc; this.updateSourceCaches_(techSrc); diff --git a/test/unit/sourceset.test.js b/test/unit/sourceset.test.js index 6324c51ca2..1c034d29cb 100644 --- a/test/unit/sourceset.test.js +++ b/test/unit/sourceset.test.js @@ -1194,4 +1194,41 @@ QUnit[qunitFn]('sourceset', function(hooks) { player.src(youtubeSrc); }); + + QUnit.test('tech sourceset update sources cache when changingSrc_ is false', function(assert) { + const clock = sinon.useFakeTimers(); + const fixture = document.querySelector('#qunit-fixture'); + const vid = document.createElement('video'); + + fixture.appendChild(vid); + + const player = videojs(vid); + + player.src(sourceOne); + + clock.tick(1); + + // Declaring the spies here avoids listening to the changes that took place when loading the source. + const handleTechSourceset_ = sinon.spy(player, 'handleTechSourceset_'); + const techGet_ = sinon.spy(player, 'techGet_'); + const updateSourceCaches_ = sinon.spy(player, 'updateSourceCaches_'); + + player.tech_.trigger('sourceset'); + + assert.ok(handleTechSourceset_.calledOnce, 'handleTechSourceset_ was called'); + assert.ok(!techGet_.called, 'techGet_ was not called'); + assert.ok(updateSourceCaches_.calledOnce, 'updateSourceCaches_ was called'); + assert.equal(player.cache_.src, '', 'player.cache_.src was reset'); + + player.tech_.trigger('loadstart'); + + assert.ok(techGet_.called, 'techGet_ was called'); + assert.equal(updateSourceCaches_.callCount, 2, 'updateSourceCaches_ was called twice'); + + handleTechSourceset_.restore(); + techGet_.restore(); + updateSourceCaches_.restore(); + player.dispose(); + clock.restore(); + }); });