Skip to content

Commit

Permalink
fix: make compatible with chrome 53 (#8354)
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben authored Jul 12, 2023
1 parent 8dd98f6 commit c66bf40
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3100,7 +3100,7 @@ class Player extends Component {
Dom.copyStyleSheetsToWindow(pipWindow);
this.el_.parentNode.insertBefore(pipContainer, this.el_);

pipWindow.document.body.append(this.el_);
pipWindow.document.body.appendChild(this.el_);
pipWindow.document.body.classList.add('vjs-pip-window');

this.player_.isInPictureInPicture(true);
Expand All @@ -3110,7 +3110,7 @@ class Player extends Component {
pipWindow.addEventListener('pagehide', (event) => {
const pipVideo = event.target.querySelector('.video-js');

pipContainer.replaceWith(pipVideo);
pipContainer.parentNode.replaceChild(pipVideo, pipContainer);
this.player_.isInPictureInPicture(false);
this.player_.trigger('leavepictureinpicture');
});
Expand Down
4 changes: 3 additions & 1 deletion src/js/tracks/text-track-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ class TextTrackDisplay extends Component {
* a {@link Player#texttrackchange} or a {@link Player#fullscreenchange} is fired.
*/
updateDisplayOverlay() {
if (!this.player_.videoHeight()) {
// inset-inline and inset-block are not supprted on old chrome, but these are
// only likely to be used on TV devices
if (!this.player_.videoHeight() || !window.CSS.supports('inset-inline: 10px')) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function videojs(id, options, ready) {
// If the document is no longer attached to the dom, the defaultView of the document will be null.
// If element is inside Shadow DOM (e.g. is part of a Custom element), ownerDocument.body
// always returns false. Instead, use the Shadow DOM root.
const inShadowDom = el.getRootNode() instanceof window.ShadowRoot;
const inShadowDom = 'getRootNode' in el ? el.getRootNode() instanceof window.ShadowRoot : false;
const rootNode = inShadowDom ? el.getRootNode() : el.ownerDocument.body;

if (!el.ownerDocument.defaultView || !rootNode.contains(el)) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2848,7 +2848,7 @@ QUnit.test('document pictureinpicture is opt-in', function(assert) {

player.requestPictureInPicture().catch(e => {
assert.equal(e, 'No PiP mode is available', 'docPiP not used when not enabled');
}).finally(_ => {
}).then(_ => {
if (window.documentPictureInPicture === testPiPObj) {
delete window.documentPictureInPicture;
}
Expand Down Expand Up @@ -2888,7 +2888,7 @@ QUnit.test('docPiP is used in preference to winPiP', function(assert) {
assert.ok(true, 'docPiP was called');
}).catch(_ => {
assert.ok(true, 'docPiP was called');
}).finally(_ => {
}).then(_ => {
assert.equal(0, count, 'requestPictureInPicture not passed to tech');
if (window.documentPictureInPicture === testPiPObj) {
delete window.documentPictureInPicture;
Expand Down
4 changes: 3 additions & 1 deletion test/unit/tracks/text-track-display.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ if (!Html5.supportsNativeTextTracks()) {
);
});

QUnit.test('text track display should overlay a video', function(assert) {
const skipOnOldChrome = window.CSS.supports('inset-inline: 10px') ? 'test' : 'skip';

QUnit[skipOnOldChrome]('text track display should overlay a video', function(assert) {
const tag = document.createElement('video');

tag.width = 320;
Expand Down
5 changes: 4 additions & 1 deletion test/unit/utils/custom-element.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ export class TestCustomElement extends HTMLElement {
}
}

window.customElements.define('test-custom-element', TestCustomElement);
// Not supported on Chrome < 54
if ('customElements' in window) {
window.customElements.define('test-custom-element', TestCustomElement);
}
5 changes: 4 additions & 1 deletion test/unit/video.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import videojs from '../../src/js/video.js';
import * as Dom from '../../src/js/utils/dom.js';
import log from '../../src/js/utils/log.js';
import document from 'global/document';
import window from 'global/window';
import sinon from 'sinon';
// import custom element for Shadow DOM test
import './utils/custom-element.test';
Expand Down Expand Up @@ -86,7 +87,9 @@ QUnit.test(
}
);

QUnit.test(
const skipWithoutCustomElements = 'customElements' in window ? 'test' : 'skip';

QUnit[skipWithoutCustomElements](
'should not log if the supplied element is included in the Shadow DOM',
function(assert) {
const origWarnLog = log.warn;
Expand Down

0 comments on commit c66bf40

Please sign in to comment.