Skip to content

Commit

Permalink
Tests: Fix selector tests in Chrome
Browse files Browse the repository at this point in the history
For older Safari/iOS we needed to add the `safari` UA check as their reported
`WebKit` version was not new enough. However, that check should have also
excluded Chrome which was missed in the first iteration. This has been fixed.

Also, fix code formatting in `test/unit/css.js`.
  • Loading branch information
mgol committed Jan 24, 2023
1 parent da7057e commit 732592c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 6 additions & 5 deletions test/unit/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -1773,11 +1773,12 @@ QUnit.test( "Do not throw on frame elements from css method (trac-15098)", funct
"</style>"
);

var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
$elem = jQuery( "<div>" ).addClass( "test__customProperties" )
.appendTo( "#qunit-fixture" ),
webkitOrBlink = /\webkit\b/i.test( navigator.userAgent ) && !/edge\//i.test( navigator.userAgent ),
expected = 20;
var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
$elem = jQuery( "<div>" ).addClass( "test__customProperties" )
.appendTo( "#qunit-fixture" ),
webkitOrBlink = /\webkit\b/i.test( navigator.userAgent ) &&
!/edge\//i.test( navigator.userAgent ),
expected = 20;

if ( webkitOrBlink ) {
expected -= 2;
Expand Down
9 changes: 6 additions & 3 deletions test/unit/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ QUnit.module( "selector", {
// in the Chromium UA, but it is locked to an older version there.
// Modern WebKit (Safari 13+) locks it to `605.1.15`.
// Since the `3.x` branch is also tested on older WebKit UAs, we
// need the `Safari` check as well.
this.safari = /\bapplewebkit\/605\.1\.15\b/i.test( navigator.userAgent ) ||
/\bsafari\b/i.test( navigator.userAgent );
// need the `Safari` check as well. Chrome also includes the `Safari`
// token, though, so we need to explicitly exclude it.
this.safari = /\bapplewebkit\/605\.1\.15\b/i.test( navigator.userAgent ) || (
/\bsafari\b/i.test( navigator.userAgent ) &&
!/\b(?:headless)?chrome\b/i.test( navigator.userAgent )
);
},
afterEach: moduleTeardown
} );
Expand Down

0 comments on commit 732592c

Please sign in to comment.