diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/ajax.js | 2 | ||||
-rw-r--r-- | test/unit/css.js | 2 | ||||
-rw-r--r-- | test/unit/selector.js | 8 | ||||
-rw-r--r-- | test/unit/support.js | 23 |
4 files changed, 28 insertions, 7 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 18e36489d..166d31de0 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -2270,7 +2270,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re // beforeunload, unload, pagehide, and visibilitychange event handlers. // See https://bugs.chromium.org/p/chromium/issues/detail?id=952452 // Safari 13 did similar changes. The below check will catch them both. - if ( !/safari/i.test( navigator.userAgent ) ) { + if ( !/webkit/i.test( navigator.userAgent ) ) { testIframe( "trac-14379 - jQuery.ajax() on unload", "ajax/onunload.html", diff --git a/test/unit/css.js b/test/unit/css.js index a7a501df1..e4a11175f 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1757,7 +1757,7 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) { var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ), $elem = jQuery( "<div>" ).addClass( "test__customProperties" ) .appendTo( "#qunit-fixture" ), - webkitOrBlink = /\bsafari\b/i.test( navigator.userAgent ), + webkitOrBlink = /\webkit\b/i.test( navigator.userAgent ), expected = 20; if ( webkitOrBlink ) { diff --git a/test/unit/selector.js b/test/unit/selector.js index d177ab997..649b1e225 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -1,7 +1,11 @@ QUnit.module( "selector", { beforeEach: function() { - this.safari = /\bsafari\b/i.test( navigator.userAgent ) && - !/\b(?:headless)?chrome\b/i.test( navigator.userAgent ); + + // Playwright WebKit on macOS doesn't expose `Safari` in its user agent + // string; use the "AppleWebKit" token. This token is also present + // in the Chromium UA, but it is locked to an older version there. + // Modern WebKit (Safari 13+) locks it to `605.1.15`. + this.safari = /\bapplewebkit\/605\.1\.15\b/i.test( navigator.userAgent ); }, afterEach: moduleTeardown } ); diff --git a/test/unit/support.js b/test/unit/support.js index dc50700e8..aa3386ef8 100644 --- a/test/unit/support.js +++ b/test/unit/support.js @@ -70,6 +70,10 @@ testIframe( cssSupportsSelector: false, reliableTrDimensions: true }, + webkit: { + cssSupportsSelector: true, + reliableTrDimensions: true + }, firefox_102: { cssSupportsSelector: false, reliableTrDimensions: false @@ -97,14 +101,26 @@ testIframe( // Catches Edge, Chrome on Android & Opera as well. expected = expectedMap.chrome; - } else if ( /\b\d+(\.\d+)+ safari/i.test( userAgent ) ) { - expected = expectedMap.safari; } else if ( /firefox\/102\./i.test( userAgent ) ) { expected = expectedMap.firefox_102; } else if ( /firefox/i.test( userAgent ) ) { expected = expectedMap.firefox; } else if ( /(?:iphone|ipad);.*(?:iphone)? os \d+_/i.test( userAgent ) ) { expected = expectedMap.ios; + } else if ( typeof URLSearchParams !== "undefined" && + + // `karma-webkit-launcher` adds `test_browser=Playwright` to the query string. + // The normal way of using user agent to detect the browser won't help + // as on macOS Playwright doesn't specify the `Safari` token but on Linux + // it does. + // See https://github.com/google/karma-webkit-launcher#detected-if-safari-or-playwright-is-used + new URLSearchParams( document.referrer || window.location.search ).get( + "test_browser" + ) === "Playwright" + ) { + expected = expectedMap.webkit; + } else if ( /\b\d+(\.\d+)+ safari/i.test( userAgent ) ) { + expected = expectedMap.safari; } QUnit.test( "Verify that support tests resolve as expected per browser", function( assert ) { @@ -134,7 +150,8 @@ testIframe( for ( i in expected ) { assert.equal( computedSupport[ i ], expected[ i ], "jQuery.support['" + i + "']: " + computedSupport[ i ] + - ", expected['" + i + "']: " + expected[ i ] ); + ", expected['" + i + "']: " + expected[ i ] + + ";\nUser Agent: " + navigator.userAgent ); } } ); |