Skip to content

Commit

Permalink
Tests: Indicate Chrome 112 & Safari 16.4 pass the cssHas support test…
Browse files Browse the repository at this point in the history
… (3.x version)

Chrome 112 & Safari 16.4 introduce two changes:
* `:has()` is non-forgiving
* `CSS.supports( "selector(...)" )` parses everything in a non-forgiving way

We no longer care about the latter but the former means the `cssHas` support
test now passes.

Closes gh-5226
  • Loading branch information
mgol committed Apr 4, 2023
1 parent 7bb48a0 commit 1a4d87a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ function setDocument( node ) {
return document.querySelectorAll( ":scope" );
} );

// Support: Chrome 105 - 110+, Safari 15.4 - 16.3+
// Make sure the the `:has()` argument is parsed unforgivingly.
// Support: Chrome 105 - 111 only, Safari 15.4 - 16.3 only
// Make sure the `:has()` argument is parsed unforgivingly.
// We include `*` in the test to detect buggy implementations that are
// _selectively_ forgiving (specifically when the list includes at least
// one valid selector).
Expand Down
102 changes: 76 additions & 26 deletions test/unit/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ testIframe(
sortDetached: true,
sortStable: true
},
chrome: {
chrome_111: {
ajax: true,
boxSizingReliable: true,
checkClone: true,
Expand All @@ -154,7 +154,31 @@ testIframe(
sortDetached: true,
sortStable: true
},
safari: {
chrome: {
ajax: true,
boxSizingReliable: true,
checkClone: true,
checkOn: true,
clearCloneStyle: true,
cssHas: true,
cors: true,
createHTMLDocument: true,
disconnectedMatch: true,
getById: true,
noCloneChecked: true,
option: true,
optSelected: true,
pixelBoxStyles: true,
pixelPosition: true,
radioValue: true,
reliableMarginLeft: true,
reliableTrDimensions: true,
scope: true,
scrollboxSize: true,
sortDetached: true,
sortStable: true
},
safari_16_3: {
ajax: true,
boxSizingReliable: true,
checkClone: true,
Expand All @@ -178,7 +202,7 @@ testIframe(
sortDetached: true,
sortStable: true
},
webkit: {
safari: {
ajax: true,
boxSizingReliable: true,
checkClone: true,
Expand All @@ -202,7 +226,7 @@ testIframe(
sortDetached: true,
sortStable: true
},
firefox_60: {
webkit: {
ajax: true,
boxSizingReliable: true,
checkClone: true,
Expand All @@ -219,14 +243,14 @@ testIframe(
pixelBoxStyles: true,
pixelPosition: true,
radioValue: true,
reliableMarginLeft: false,
reliableMarginLeft: true,
reliableTrDimensions: true,
scope: true,
scrollboxSize: true,
sortDetached: true,
sortStable: true
},
firefox_102: {
firefox_60: {
ajax: true,
boxSizingReliable: true,
checkClone: true,
Expand All @@ -243,8 +267,8 @@ testIframe(
pixelBoxStyles: true,
pixelPosition: true,
radioValue: true,
reliableMarginLeft: true,
reliableTrDimensions: false,
reliableMarginLeft: false,
reliableTrDimensions: true,
scope: true,
scrollboxSize: true,
sortDetached: true,
Expand Down Expand Up @@ -370,7 +394,7 @@ testIframe(
sortDetached: true,
sortStable: true
},
ios: {
ios_15_4_16_3: {
ajax: true,
boxSizingReliable: true,
checkClone: true,
Expand All @@ -394,6 +418,30 @@ testIframe(
sortDetached: true,
sortStable: true
},
ios: {
ajax: true,
boxSizingReliable: true,
checkClone: true,
checkOn: true,
clearCloneStyle: true,
cssHas: true,
cors: true,
createHTMLDocument: true,
disconnectedMatch: true,
getById: true,
noCloneChecked: true,
option: true,
optSelected: true,
pixelBoxStyles: true,
pixelPosition: true,
radioValue: true,
reliableMarginLeft: true,
reliableTrDimensions: true,
scope: true,
scrollboxSize: true,
sortDetached: true,
sortStable: true
},
android: {
ajax: true,
boxSizingReliable: true,
Expand Down Expand Up @@ -440,36 +488,36 @@ testIframe(
}
}

if ( /edge\//i.test( userAgent ) ) {
if ( /\bedge\//i.test( userAgent ) ) {
expected = expectedMap.edge;
} else if ( /msie 9\.0/i.test( userAgent ) ) {
} else if ( /\bmsie 9\.0/i.test( userAgent ) ) {
expected = expectedMap.ie_9;
} else if ( /(msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) {
} else if ( /\b(?:msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) {
expected = expectedMap.ie_10_11;
} else if ( /chrome/i.test( userAgent ) ) {
} else if ( /\b(?:headless)?chrome\/(?:10\d|11[01])\b/i.test( userAgent ) ) {
expected = expectedMap.chrome_111;
} else if ( /\b(?:headless)?chrome\//i.test( userAgent ) ) {

// Catches Chrome on Android as well (i.e. the default
// Android browser on Android >= 4.4).
expected = expectedMap.chrome;
} else if ( /\b(?:9|10)\.\d+(\.\d+)* safari/i.test( userAgent ) ) {
expected = expectedMap.safari_9_10;
} else if ( /firefox\/[456]\d\b/i.test( userAgent ) ) {
} else if ( /\bfirefox\/[456]\d\b/i.test( userAgent ) ) {
expected = expectedMap.firefox_60;
} else if ( /firefox\/(?:[789]\d|102)\b/i.test( userAgent ) ) {
expected = expectedMap.firefox_102;
} else if ( /firefox/i.test( userAgent ) ) {
} else if ( /\bfirefox\//i.test( userAgent ) ) {
expected = expectedMap.firefox;
} else if ( /android 4\.[0-3]/i.test( userAgent ) ) {
} else if ( /\bandroid 4\.[0-3]/i.test( userAgent ) ) {
expected = expectedMap.android;
} else if ( /iphone os 7_/i.test( userAgent ) ) {
} else if ( /\biphone os 7_/i.test( userAgent ) ) {
expected = expectedMap.ios_7;
} else if ( /iphone os 8_/i.test( userAgent ) ) {
} else if ( /\biphone os 8_/i.test( userAgent ) ) {
expected = expectedMap.ios_8;
} else if ( /iphone os (?:9|10)_/i.test( userAgent ) ) {
} else if ( /\biphone os (?:9|10)_/i.test( userAgent ) ) {
expected = expectedMap.ios_9_10;
} else if ( /iphone os (?:1[1234]_|15_[0123])/i.test( userAgent ) ) {
} else if ( /\biphone os (?:1[1234]_|15_[0123])/i.test( userAgent ) ) {
expected = expectedMap.ios_11_15_3;
} else if ( /(?:iphone|ipad);.*(?:iphone)? os \d+_/i.test( userAgent ) ) {
} else if ( /\biphone os (?:15_|16_[0123])/i.test( userAgent ) ) {
expected = expectedMap.ios_15_4_16_3;
} else if ( /\b(?:iphone|ipad);.*(?:iphone)? os \d+_/i.test( userAgent ) ) {
expected = expectedMap.ios;
} else if ( typeof URLSearchParams !== "undefined" &&

Expand All @@ -483,7 +531,9 @@ testIframe(
) === "Playwright"
) {
expected = expectedMap.webkit;
} else if ( /\b\d+(\.\d+)+ safari/i.test( userAgent ) ) {
} else if ( /\bversion\/(?:15|16\.[0123])(?:\.\d+)* safari/i.test( userAgent ) ) {
expected = expectedMap.safari_16_3;
} else if ( /\bversion\/\d+(?:\.\d+)+ safari/i.test( userAgent ) ) {
expected = expectedMap.safari;
}

Expand Down

0 comments on commit 1a4d87a

Please sign in to comment.