@@ -107,19 +107,17 @@ testIframe(
107107 expected = expectedMap . firefox ;
108108 } else if ( / (?: i p h o n e | i p a d ) ; .* (?: i p h o n e ) ? o s \d + _ / i. test ( userAgent ) ) {
109109 expected = expectedMap . ios ;
110- } else if (
111-
112- // Playwright WebKit on macOS doesn't expose `Safari` in its user agent string.
113- // However, this particular version of WebKit is only present in modern
114- // WebKit UAs (Safari 13+) as Chromium is locked to an older version.
115- ( / \b a p p l e w e b k i t \/ 6 0 5 \. 1 \. 1 5 \b / i. test ( userAgent ) &&
116- ! / \b s a f a r i \/ / i. test ( userAgent ) ) ||
117-
118- // The Linux version of Playwright WebKit does include the `Safari` token,
119- // though. Since there's no WebKit-based real browser that we officially
120- // support outside of macOS and GitHub Actions run on Linux, use it to
121- // detect Playwright WebKit.
122- / \b l i n u x [ ^ ) ] + \) a p p l e w e b k i t \/ 6 0 5 \. 1 \. 1 5 \b / i. test ( userAgent ) ) {
110+ } else if ( typeof URLSearchParams !== "undefined" &&
111+
112+ // `karma-webkit-launcher` adds `test_browser=Playwright` to the query string.
113+ // The normal way of using user agent to detect the browser won't help
114+ // as on macOS Playwright doesn't specify the `Safari` token but on Linux
115+ // it does.
116+ // See https://github.com/google/karma-webkit-launcher#detected-if-safari-or-playwright-is-used
117+ new URLSearchParams ( document . referrer || window . location . search ) . get (
118+ "test_browser"
119+ ) === "Playwright"
120+ ) {
123121 expected = expectedMap . webkit ;
124122 } else if ( / \b \d + ( \. \d + ) + s a f a r i / i. test ( userAgent ) ) {
125123 expected = expectedMap . safari ;
0 commit comments