Skip to content
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

new_audit(tap-targets): check that tap targets are big enough and don't overlap #5846

Merged
merged 107 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
b0969df
Support multi line outerHTML snippets
mattzeunert Nov 15, 2018
30669ce
WIP
mattzeunert Nov 15, 2018
db12c55
Check each target for overlap failure, even if it is already involved…
mattzeunert Nov 15, 2018
f44c2fa
Fix table
mattzeunert Nov 15, 2018
cd6ec76
makeClientRects helper function
mattzeunert Nov 15, 2018
9fc3125
Clean up gatherer
mattzeunert Nov 15, 2018
366f033
Filter out tiny client rects
mattzeunert Nov 15, 2018
4823e53
Clean up client rect functions
mattzeunert Nov 15, 2018
b943ffd
Improve data available for debugging/tweaking finger size
mattzeunert Nov 15, 2018
c0ad3b1
Tweak table titles
mattzeunert Nov 15, 2018
34e0257
Rename BCR to client rects
mattzeunert Nov 15, 2018
c70ec6e
Move getNodePath to page functions
mattzeunert Nov 15, 2018
f80ef46
Add path to tap target node info
mattzeunert Nov 15, 2018
440c86e
Add node selector to tap target node info
mattzeunert Nov 15, 2018
7abf3cc
Show nothing instead of "n/a" when tap target isn't overlapped
mattzeunert Nov 15, 2018
0354ec8
Remove outdated comment
mattzeunert Nov 15, 2018
9da794c
Fix TS error
mattzeunert Nov 15, 2018
3593623
Only report targets that are overlapped
mattzeunert Nov 18, 2018
a5c4e2f
Rename targetA and targetB
mattzeunert Nov 18, 2018
e5fb2c2
Tweak audit description
mattzeunert Nov 18, 2018
b64a67d
Add more data for debugging
mattzeunert Nov 18, 2018
6256103
Move type def
mattzeunert Nov 18, 2018
4048f8a
Fix linting
mattzeunert Nov 18, 2018
52d9b4b
Clean up audit code
mattzeunert Nov 19, 2018
ba1490e
Update snaphots
mattzeunert Nov 19, 2018
d38f6da
Tweak comment
mattzeunert Nov 19, 2018
8bb5460
Fix accessibility smoke test
mattzeunert Nov 19, 2018
1e45c4c
Ignore missing artifacts error
mattzeunert Nov 19, 2018
409b5be
Don't merge client rects if center of merged rect is outside original…
mattzeunert Nov 19, 2018
c705dfd
Fix gatherer
mattzeunert Nov 21, 2018
7e183d9
Change display value to focus less on number of issues
mattzeunert Nov 25, 2018
2fa0ef4
Merge branch 'master' into HEAD
mattzeunert Nov 25, 2018
acb63f9
Move rect helpers to client rect functions
Nov 29, 2018
3f74c94
Add more comments to audit code
Nov 29, 2018
1183b38
Add test case for fully contained tap target
Nov 29, 2018
29fb07a
Add tap targets smoke test
Nov 29, 2018
0f76dbb
Tidy up audit logic
Nov 29, 2018
7bb75b6
Explain convert DOMRect to plain object
Nov 29, 2018
45cc9ea
Use getElementsInDocument
Nov 29, 2018
9e9af23
Fix code cov error
Nov 29, 2018
19a918f
Add extra if branch comments
Nov 29, 2018
e4c7791
Don't mark invisible but displayed elements as inVisible
Dec 2, 2018
c3b1e2c
Rename checkClientRectsInsideParents param
Dec 2, 2018
50d98ed
Fix spelling
mattzeunert Dec 2, 2018
a8f039d
New scoring logic
mattzeunert Dec 2, 2018
d78bc27
fixup Don't mark invisible but displayed elements as inVisible Matt …
mattzeunert Dec 7, 2018
c9d8f2e
WIP fix handling of partially hidden tap targets
mattzeunert Dec 7, 2018
0e80231
Merge branch 'master' into HEAD
mattzeunert Dec 7, 2018
44ad070
Fix audit tap target test
mattzeunert Dec 7, 2018
df7615d
wip
mattzeunert Dec 7, 2018
302c04e
core(minification): properly handle regex character classes (#6745)
patrickhulce Dec 7, 2018
a7e8ffb
core(tap-targets): helper functions for working with ClientRects (#6703)
mattzeunert Dec 7, 2018
e873dbb
report: larger margins for audit group summaries (#6688)
brendankenny Dec 7, 2018
7201f6b
core(service-worker): check that start_url is within SW's scope (#6678)
brendankenny Dec 7, 2018
974e277
Fix after merge
mattzeunert Dec 8, 2018
7c59b8c
Ignore position absolute tap targets
mattzeunert Dec 8, 2018
3b49651
remove old files
mattzeunert Dec 8, 2018
61e0a81
Tweaks
mattzeunert Dec 8, 2018
7121672
Tweak
mattzeunert Dec 8, 2018
1f54523
Merge branch 'master' into HEAD
mattzeunert Dec 8, 2018
05fa8b9
Tidy up code
mattzeunert Dec 8, 2018
2f09fd4
Add smoke test for invisible position absolute tap target
mattzeunert Dec 8, 2018
e6c51a8
Remove memoize isVisibleNode since at least in its current form it do…
mattzeunert Dec 8, 2018
64d184b
Add comment
mattzeunert Dec 8, 2018
e9de137
singular
mattzeunert Dec 8, 2018
5dd5c40
Ignore tap targets that are nested inside a parent
mattzeunert Dec 12, 2018
e6fbf8a
Smoke test for overlapping tap targets with same href
mattzeunert Dec 12, 2018
4701c24
Merge rects more generously
mattzeunert Dec 12, 2018
465fcc0
Fix skipping tap targets when going through ancestors, stop just befo…
mattzeunert Dec 12, 2018
9933b30
Add smoke test for position absolute tap target fully contained by an…
mattzeunert Jan 4, 2019
b3228f1
Move allRectsContainedWithinEachOther out of loop
mattzeunert Jan 4, 2019
d9a5a57
Tweaks/renaming
mattzeunert Jan 4, 2019
d5b1cf9
Don't report symmetric failures twice
mattzeunert Jan 4, 2019
9e1a0ef
Fix type
mattzeunert Jan 4, 2019
1459fb9
Tweak
mattzeunert Jan 4, 2019
767e13e
Merge branch 'master' into HEAD
mattzeunert Jan 4, 2019
13e5193
Update sample json
mattzeunert Jan 4, 2019
cd6ee28
Feedback Fixes
mattzeunert Jan 6, 2019
8188e6b
Truncate outerHTML at 300 chars
mattzeunert Jan 6, 2019
21c154e
Rename uniqueOverlapFailures to overlapFailuresForDisplay
mattzeunert Jan 8, 2019
ccf0418
Change TapTargetTableItem to interface
mattzeunert Jan 8, 2019
a1e134f
Move comment
mattzeunert Jan 19, 2019
d3595e2
Merge branch 'master' into HEAD
mattzeunert Jan 19, 2019
a33f181
Change Viewport artifact dependency to MetaElements
mattzeunert Jan 19, 2019
1dd2d3d
Node -> Element
mattzeunert Jan 19, 2019
928cf76
Explain why we only check content in text nodes for elementIsInTextBlock
mattzeunert Jan 19, 2019
2c95d32
Type fix
mattzeunert Jan 19, 2019
7793a58
Move ClientRectOverlapFailure/TapTargetOverlapFailure out of audit.d.ts
mattzeunert Jan 19, 2019
c2c2896
Don't crash if Element.prototype.matches is overridden
mattzeunert Jan 19, 2019
0138978
Tweaks
mattzeunert Jan 19, 2019
1fc2c8f
Add full audit error to smoke test expectations
mattzeunert Jan 19, 2019
900dd3f
Fix line length
mattzeunert Jan 19, 2019
9f58755
Use useIsolation to handle matches being overwritten
mattzeunert Jan 23, 2019
5bfd792
Move hasTextNodeSiblingsFormingTextBlock outside function block
mattzeunert Jan 23, 2019
d320c4f
Remove unnecessary if statement
mattzeunert Jan 23, 2019
a001852
Remove ThemeColor/Viewport that was restored during merge
mattzeunert Jan 23, 2019
be53ec6
Removed unused window var
mattzeunert Jan 23, 2019
ba795c7
Add test case for overwritten matches function
mattzeunert Jan 23, 2019
8fd667c
Make failed viewport audit message in tap targets/font size more spec…
mattzeunert Jan 24, 2019
efec03b
Fix tests following previous change
mattzeunert Jan 24, 2019
f58fe21
Fix line length for previous changes
mattzeunert Jan 24, 2019
4ae7575
Tweaks
mattzeunert Jan 24, 2019
de60ebb
Shorten getTableItems code
mattzeunert Jan 24, 2019
7d497ae
Move TapTargetTableItem type
mattzeunert Jan 24, 2019
1597590
Add test case for no viewport meta tag
mattzeunert Jan 24, 2019
2a33179
Test case for only one tap target in a pair failing
mattzeunert Jan 24, 2019
729eaaf
Rename test options to make more sense
mattzeunert Jan 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ Object {
Object {
"path": "seo/robots-txt",
},
Object {
"path": "seo/tap-targets",
},
Object {
"path": "seo/hreflang",
},
Expand Down Expand Up @@ -946,6 +949,11 @@ Object {
"id": "plugins",
"weight": 1,
},
Object {
"group": "seo-mobile",
"id": "tap-targets",
"weight": 1,
},
Object {
"id": "mobile-friendly",
"weight": 0,
Expand Down Expand Up @@ -1107,6 +1115,9 @@ Object {
Object {
"path": "seo/robots-txt",
},
Object {
"path": "seo/tap-targets",
},
],
"networkQuietThresholdMs": 1000,
"passName": "defaultPass",
Expand Down
116 changes: 116 additions & 0 deletions lighthouse-cli/test/fixtures/seo/seo-tap-targets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<!doctype html>
<!--
* Copyright 2018 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-->

<html>
<head>
<title>SEO tap target audit tester</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<style>
a {
color: blue;
}
body {
margin: 0;
}
</style>
</head>
<body>
<!-- Big tap target, but it's invisible because it's behind the main content div -->
<a style="background: red; position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: -1;"></a>
<div style="background: white; padding: 20px;">
<h1>SEO Tap targets</h1>

<!-- Invisible nodes don't cause failures -->
<div>
<!-- Scroll container hides the child -->
<div style="height: 1px; overflow: auto;">
<a style="display: inline-block; height: 1000px; width: 1000px"></a>
</div>
<!-- Various invisible tap targets-->
<a></a>
<a style="width: 0;height:0;display:inline-block;">0</a>
<a style="display: none">display none</a>
<span style="display: none"><a>display none parent</a></span>
<a style="display: inline-block; width: 0; overflow-x: hidden;height: 1px">
width 0 and overflow x hidden
</a>
<!-- Visible target should not fail because nothing overlaps it -->
<a>visible target</a>
</div>
<br/><br/>


<div style="overflow: hidden; position: relative">
<!-- Should be counted as visible although part of it is outside the scroll container -->
<a>
<div style="position: absolute;top: -100px">invisible</div>
visible
</a>
</div>

<br/><br/>

<!-- Link contains large inline block element - no failure because finger
should be placed in the center of the whole link area -->
<a style="background: red;">
<div style="display: inline-block; height: 30px; width: 30px; background: orange;"></div>
Link
</a>
<br/>
<a style="display: block; padding: 30px; background: #ddf;">
Link that the top one would overlap with, if it weren't for the inline-block child.
</a>

<br/><br/>

<div role="button">
Tap target with children that are also tap targets should not fail.
(Children should not be counted as independent tap targets that appear
in the list.)
Two children to make sure the two children also don't conflict with each other:
<a>Child 1</a><a>Child2</a>
</div>

<br/><br/>

<div style="position: relative">
<a style="display: block; position: absolute; top:0; height: 40px; width: 40px;">inner</a>
<a style="display: block; height: 100px; width: 100px; background: yellowgreen">outer</a>
</div>

<br/><br/>

<!-- Only target that's being overlapped should fail, the overlapping one shouldn't -->
<div>
<a style="display: block; width: 100px; height: 30px;background: #ddd;">
too small target
</a>
<a style="display: block; width: 100px; height: 100px;background: #aaa;">
big enough target
</a>
</div>

<br/><br/>

<!-- Should not fail if the two links have the same link target -->
<div>
<a style="display: block; width: 10px; height: 10px;" href="../seo/"></a>
<a style="display: block; width: 10px; height: 10px;" href="./"></a>
</div>

<!-- Links in text blocks are exempted from size/overlap requirements and should not fail -->
<p style="width: 100px">
This is <a>a link in a text block.</a>
This is <a>a link in a text block.</a>
This is <a>a link in a text block.</a>
This is <a>a link in a text block.</a>
This is <a>a link in a text block.</a>
</p>
</div>
</body>
</html>
37 changes: 37 additions & 0 deletions lighthouse-cli/test/smokehouse/seo/expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,41 @@ module.exports = [
},
},
},
{
requestedUrl: BASE_URL + 'seo-tap-targets.html',
finalUrl: BASE_URL + 'seo-tap-targets.html',
audits: {
'tap-targets': {
score: 0.9, // 10 passing targets/11 total visible targets
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,2,DIV,21,DIV,0,A',
'selector': 'body > div > div > a',
},
'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,2,DIV,21,DIV,1,A',
'selector': 'body > div > div > a',
},
'size': '100x30',
'width': 100,
'height': 30,
'tapTargetScore': 1440,
'overlappingTargetScore': 432,
'overlapScoreRatio': 0.3,
},
],
},
},
},
},
];
Loading