From 452a918a42705aff64a6516328523f097b3e37f3 Mon Sep 17 00:00:00 2001 From: mister-ben Date: Wed, 19 Jul 2023 09:10:07 +0200 Subject: [PATCH] fix(tests): Skip a test on old Safari (#8356) --- test/unit/utils/dom.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/unit/utils/dom.test.js b/test/unit/utils/dom.test.js index bda4bdda36..0eb280b520 100644 --- a/test/unit/utils/dom.test.js +++ b/test/unit/utils/dom.test.js @@ -1,7 +1,9 @@ /* eslint-env qunit */ import document from 'global/document'; +import window from 'global/window'; import sinon from 'sinon'; import * as Dom from '../../../src/js/utils/dom.js'; +import { IS_SAFARI } from '../../../src/js/utils/browser.js'; import TestHelpers from '../test-helpers.js'; QUnit.module('utils/dom'); @@ -687,7 +689,11 @@ QUnit.test('isSingleLeftClick() checks return values for mousedown event', funct assert.ok(Dom.isSingleLeftClick(mouseEvent), 'a touch event on simulated mobiles is a single left click'); }); -QUnit.test('Dom.copyStyleSheetsToWindow() copies all style sheets to a window', function(assert) { +// The next test is skipped on Safari < 14, which has a broken document.styleSheets +// copyStyleSheetsToWindow() is only used on browsers supporting documentPictureInPicture - Chromium 113+ +const skipOnOldSafari = IS_SAFARI && parseInt(window.navigator.userAgent.match(/Version\/(\d+)\./)[1], 10) < 14 ? 'skip' : 'test'; + +QUnit[skipOnOldSafari]('Dom.copyStyleSheetsToWindow() copies all style sheets to a window', function(assert) { const fakeWindow = document.createElement('div'); const done = assert.async();