Skip to content

Commit

Permalink
add browser.IS_CHROMECAST_RECEIVER and class name for CSS targeting o…
Browse files Browse the repository at this point in the history
…n a Chromecast receiver where Video.js is used (#8703)
  • Loading branch information
misteroneill authored May 30, 2024
1 parent ad357b5 commit 91e5e2d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,8 @@ class Player extends Component {
'IS_WEBOS',
'IS_ANDROID',
'IS_IPAD',
'IS_IPHONE'
'IS_IPHONE',
'IS_CHROMECAST_RECEIVER'
].filter(key => browser[key]).map(key => {
return 'vjs-device-' + key.substring(3).toLowerCase().replace(/\_/g, '-');
});
Expand Down
8 changes: 8 additions & 0 deletions src/js/utils/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export let CHROMIUM_VERSION = null;
*/
export let CHROME_VERSION = null;

/**
* Whether or not this is a Chromecast receiver application.
*
* @static
* @type {Boolean}
*/
export const IS_CHROMECAST_RECEIVER = Boolean(window.cast && window.cast.framework && window.cast.framework.CastReceiverContext);

/**
* The detected Internet Explorer version - or `null`.
*
Expand Down
13 changes: 13 additions & 0 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,19 @@ QUnit.test('should add iphone classname when on iphone', function(assert) {
player.dispose();
});

QUnit.test('should add chromecast-receiver classname when on chromecast receiver', function(assert) {
assert.expect(1);

browser.stub_IS_CHROMECAST_RECEIVER(true);

const player = TestHelpers.makePlayer({});

assert.ok(player.hasClass('vjs-device-chromecast-receiver'), 'chromecast-receiver classname added');

browser.reset_IS_CHROMECAST_RECEIVER();
player.dispose();
});

QUnit.test('should add a svg-icons-enabled classname when svg icons are supported', function(assert) {
// Stub a successful parsing of the SVG sprite.
sinon.stub(window.DOMParser.prototype, 'parseFromString').returns({
Expand Down

0 comments on commit 91e5e2d

Please sign in to comment.