-
Notifications
You must be signed in to change notification settings - Fork 9.5k
core(tap-targets): don't exclude visible position absolute elements from audit #7778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
728c003
90404ff
d3a9a8d
06a624a
659fa88
0f8e2df
233ee73
d9d40bf
76cc42f
c2767c3
993dd77
a6d9932
463622c
7f38635
4b9f808
31d8251
8622bf4
cb4835f
7c1ed2d
1c16558
97fe391
88d5a83
b499b52
e91d5cd
810b37e
ecc7091
bc81d78
fc85de0
ab754df
8a41fef
cc44890
3593edf
abaf722
9dece7f
32a41ac
4d626a4
ccf9557
d69910a
af0fdde
6e2f54e
7183ac6
9353561
6d02ea5
f4a9ee4
8fd5e2d
b5a86d6
f20fc20
befe66e
fda7c9e
aafa240
5e3c2f8
6689f0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,60 @@ function headersParam(headers) { | |
return new URLSearchParams([['extra_header', headerString]]).toString(); | ||
} | ||
|
||
const expectedGatheredTapTargets = [ | ||
{ | ||
snippet: /large-link-at-bottom-of-page/, | ||
}, | ||
{ | ||
snippet: /visible-target/, | ||
}, | ||
{ | ||
snippet: /target-with-client-rect-outside-scroll-container/, | ||
}, | ||
{ | ||
snippet: /link-containing-large-inline-block-element/, | ||
}, | ||
{ | ||
snippet: /link-next-to-link-containing-large-inline-block-element/, | ||
}, | ||
{ | ||
snippet: /tap-target-containing-other-tap-targets/, | ||
}, | ||
{ | ||
snippet: /child-client-rect-hidden-by-overflow-hidden/, | ||
}, | ||
{ | ||
snippet: /tap-target-next-to-child-client-rect-hidden-by-overflow-hidden/, | ||
}, | ||
{ | ||
snippet: /child-client-rect-overlapping-other-target/, | ||
shouldFail: true, | ||
}, | ||
{ | ||
snippet: /tap-target-overlapped-by-other-targets-position-absolute-child-rect/, | ||
shouldFail: true, | ||
}, | ||
{ | ||
snippet: /position-absolute-tap-target-fully-contained-in-other-target/, | ||
}, | ||
{ | ||
snippet: /tap-target-fully-containing-position-absolute-target/, | ||
}, | ||
{ | ||
snippet: /too-small-failing-tap-target/, | ||
shouldFail: true, | ||
}, | ||
{ | ||
snippet: /large-enough-tap-target-next-to-too-small-tap-target/, | ||
}, | ||
{ | ||
snippet: /links-with-same-link-target-1/, | ||
}, | ||
{ | ||
snippet: /links-with-same-link-target-2/, | ||
}, | ||
]; | ||
|
||
const failureHeaders = headersParam([[ | ||
'x-robots-tag', | ||
'none', | ||
|
@@ -190,48 +244,58 @@ module.exports = [ | |
audits: { | ||
'tap-targets': { | ||
score: (() => { | ||
const PASSING_TAP_TARGETS = 11; | ||
const TOTAL_TAP_TARGETS = 12; | ||
const totalTapTargets = expectedGatheredTapTargets.length; | ||
const passingTapTargets = expectedGatheredTapTargets.filter(t => !t.shouldFail).length; | ||
const SCORE_FACTOR = 0.89; | ||
return Math.floor(PASSING_TAP_TARGETS / TOTAL_TAP_TARGETS * SCORE_FACTOR * 100) / 100; | ||
return Math.round(passingTapTargets / totalTapTargets * SCORE_FACTOR * 100) / 100; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a tad worried by how much logic ends up living in our expectations, but I sympathize with the tedium of updating these and would rather have it be more precise so 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think this might be going too far in this direction :/ It's one thing when it's broken down but still defined by constants, but since this is pulling live from the test file, it would be difficult to notice e.g. if we broke one of the overlapping tap target examples in the test page. So long as it also no longer matched the regex it would still pass and we wouldn't notice we were losing coverage. It's also nice to have a place we can point to with "here's what we expect a failing/real value for this audit to look like", and with this approach the only way to do that is to put in a breakpoint and open up a debugger. |
||
})(), | ||
details: { | ||
items: [ | ||
{ | ||
'tapTarget': { | ||
'type': 'node', | ||
'snippet': '<a ' + | ||
'style="display: block; width: 100px; height: 30px;background: #ddd;">' + | ||
'\n too small target\n </a>', | ||
'path': '2,HTML,1,BODY,3,DIV,21,DIV,0,A', | ||
'path': '2,HTML,1,BODY,10,DIV,0,DIV,1,A', | ||
'selector': 'body > div > div > a', | ||
'nodeLabel': 'too small target', | ||
}, | ||
'overlappingTarget': { | ||
'type': 'node', | ||
'snippet': '<a ' + | ||
'style="display: block; width: 100px; height: 100px;background: #aaa;">' + | ||
'\n big enough target\n </a>', | ||
'path': '2,HTML,1,BODY,3,DIV,21,DIV,1,A', | ||
'path': '2,HTML,1,BODY,10,DIV,0,DIV,2,A', | ||
'selector': 'body > div > div > a', | ||
'nodeLabel': 'big enough target', | ||
}, | ||
'size': '100x30', | ||
'width': 100, | ||
'height': 30, | ||
'tapTargetScore': 1440, | ||
'overlappingTargetScore': 432, | ||
'overlapScoreRatio': 0.3, | ||
'size': '100x30', | ||
'width': 100, | ||
'height': 30, | ||
}, | ||
{ | ||
'tapTarget': { | ||
'type': 'node', | ||
'path': '2,HTML,1,BODY,3,DIV,24,A', | ||
'selector': 'body > div > a', | ||
}, | ||
'overlappingTarget': { | ||
'type': 'node', | ||
'path': '2,HTML,1,BODY,3,DIV,25,A', | ||
'selector': 'body > div > a', | ||
}, | ||
'tapTargetScore': 1920, | ||
'overlappingTargetScore': 560, | ||
'overlapScoreRatio': 0.2916666666666667, | ||
'size': '40x40', | ||
'width': 40, | ||
'height': 40, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
artifacts: { | ||
TapTargets: { | ||
length: 11, | ||
}, | ||
TapTargets: expectedGatheredTapTargets.map(({snippet}) => ({snippet})), | ||
}, | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍 LOVIN' these tests :D