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

core(seo): move non-search audits to best practices #15930

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
20 changes: 20 additions & 0 deletions cli/test/fixtures/dobetterweb/dbw_tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@ <h2 id="toppy" style="background-image:url('');">Do better web tester page</h2>

</template>

<template id="link-text">
<h2>Anchor text</h2>
<a href='https://example.com'>click this</a>
<a href='/test.html'> click this </a>
<a href='/test.html'>CLICK THIS</a>
<svg>
<a href='https://example.com/svg-link'>
<circle cx="50" cy="50" r="50"/>
<text x="0" y="0" >click this</text>
</a>
</svg>
</template>

<!-- FAIL(image-aspect-ratio): image is naturally 1024x680 -->
<img src="lighthouse-1024x680.jpg?iar1" width="120" height="15">
<!-- PASS(image-aspect-ratio) -->
Expand Down Expand Up @@ -375,6 +388,9 @@ <h2 id="toppy" style="background-image:url('');">Do better web tester page</h2>
stampTemplate('paste-preventing-inputs', document.body);
}

function linkTextTest() {
stampTemplate('link-text', document.body);
}

function deprecationsTest() {
// TODO: some deprecated API messages are not currently being logged correctly.
Expand Down Expand Up @@ -437,6 +453,7 @@ <h2 id="toppy" style="background-image:url('');">Do better web tester page</h2>
isOnHttps();
noUnloadListenersTest();
thirdPartyCookieTest();
linkTextTest();
} else {
if (params.has('documentWrite')) {
documentWriteTest();
Expand Down Expand Up @@ -477,6 +494,9 @@ <h2 id="toppy" style="background-image:url('');">Do better web tester page</h2>
if (params.has('3pcookie')) {
thirdPartyCookieTest();
}
if (params.has('linktext')) {
linkTextTest();
}
}
</script>

Expand Down
7 changes: 7 additions & 0 deletions cli/test/fixtures/font-size-styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions cli/test/fixtures/font-size.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.small {
font-size: 11px;
}
</style>
<style> /* some filler to offset things */ .small-2 { font-size: 11px; }</style>
<style>
/* some filler to offset things */
.small-3 {
font-size: 6px;
}
/*# sourceURL=font-size-inline-magic.css */
</style>
<link rel="stylesheet" href="font-size-styles.css">
</head>
<body>
<h2>Small text but still legible</h2>
<!-- PASS(font-size): amount of illegible text is below the 60% threshold -->
<!-- font-size items are ordered by text length, so force an order with filler for stable expectations. -->
<p class='small'> 1.... </p>
<p class='small-2'> 2... </p>
<p class='small-3'> 3.. </p>
<p class='small-4'> 4. </p>
<h6>2</h6>
<font size="1">3<b>4</b></font>
<div style=''>
<p style='font-size:10px'> 5 </p>
</div>
<script class='small'>
// text from SCRIPT tags should be ignored by the font-size audit
</script>
</body>
</html>
13 changes: 0 additions & 13 deletions cli/test/fixtures/seo/seo-failure-cases.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<head>
<!-- no <title>SEO audit failures page</title> -->
<meta charset="utf-8">
<!-- FAIL(font-size): missing viewport -->
<meta name="viewport" content="invalid-content=should_have_looked_it_up">
<!-- no <meta name="description" content=""> -->
<!-- FAIL(is-crawlable): noindex on root page, vary the case to make sure we are case insensitive -->
<meta name="RoBots" content="nofollow, NOINDEX, all">
Expand All @@ -28,17 +26,6 @@
<body>
<h1>SEO</h1>

<h2>Anchor text</h2>
<a href='https://example.com'>click this</a>
<a href='/test.html'> click this </a>
<a href='/test.html'>CLICK THIS</a>
<svg>
<a href='https://example.com/svg-link'>
<circle cx="50" cy="50" r="50"/>
<text x="0" y="0" >click this</text>
</a>
</svg>

<!-- FAIL(crawlable-anchors): Link using window.open() -->
<a onclick="window.open(`http://example.com`)">Some link</a>

Expand Down
15 changes: 0 additions & 15 deletions cli/test/fixtures/seo/seo-tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ <h2>Anchor text</h2>
<a href='https://example.com/non-descriptive-no-follow.html' rel="nofollow">click this</a>
<a href='javascript:;'>click this</a>

<h2>Small text</h2>
<!-- PASS(font-size): amount of illegible text is below the 60% threshold -->
<!-- font-size items are ordered by text length, so force an order with filler for stable expectations. -->
<p class='small'> 1.... </p>
<p class='small-2'> 2... </p>
<p class='small-3'> 3.. </p>
<p class='small-4'> 4. </p>
<h6>2</h6>
<font size="1">3<b>4</b></font>
<div style=''>
<p style='font-size:10px'> 5 </p>
</div>
<script class='small'>
// text from SCRIPT tags should be ignored by the font-size audit
</script>
<!-- override global URL - bug #5701 -->
<script>URL = '';</script>

Expand Down
2 changes: 2 additions & 0 deletions cli/test/smokehouse/core-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import dbw from './test-definitions/dobetterweb.js';
import errorsExpiredSsl from './test-definitions/errors-expired-ssl.js';
import errorsIframeExpiredSsl from './test-definitions/errors-iframe-expired-ssl.js';
import errorsInfiniteLoop from './test-definitions/errors-infinite-loop.js';
import fontSize from './test-definitions/font-size.js';
import formsAutoComplete from './test-definitions/forms-autocomplete.js';
import fpsMax from './test-definitions/fps-max.js';
import fpsMaxPassive from './test-definitions/fps-max-passive.js';
Expand Down Expand Up @@ -77,6 +78,7 @@ const smokeTests = [
errorsExpiredSsl,
errorsIframeExpiredSsl,
errorsInfiniteLoop,
fontSize,
formsAutoComplete,
fpsMax,
fpsMaxPassive,
Expand Down
15 changes: 12 additions & 3 deletions cli/test/smokehouse/test-definitions/dobetterweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,15 @@ const expectations = {
},
'dom-size': {
score: 1,
numericValue: 151,
numericValue: 160,
details: {
items: [
{
statistic: 'Total DOM Elements',
value: {
type: 'numeric',
granularity: 1,
value: 151,
value: 160,
},
},
{
Expand Down Expand Up @@ -604,12 +604,21 @@ const expectations = {
viewportContent: 'width=device-width, initial-scale=1, minimum-scale=1',
},
},
'link-text': {
score: 0,
displayValue: '4 links found',
details: {
items: {
length: 4,
},
},
},
},
fullPageScreenshot: {
screenshot: {
width: 412,
// Allow for differences in platforms.
height: '1350±100',
height: '1527±100',
data: /^data:image\/webp;.{500,}/,
},
nodes: {
Expand Down
108 changes: 108 additions & 0 deletions cli/test/smokehouse/test-definitions/font-size.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @type {Smokehouse.ExpectedRunnerResult}
* Expected Lighthouse audit values for a site that fails seo tests.
*/
const expectations = {
lhr: {
requestedUrl: 'http://localhost:10200/font-size.html',
finalDisplayedUrl: 'http://localhost:10200/font-size.html',
audits: {
'font-size': {
score: 1,
details: {
items: [
{
source: {
url: 'http://localhost:10200/font-size.html',
urlProvider: 'network',
line: 6,
column: 12,
},
selector: '.small',
fontSize: '11px',
},
{
source: {
url: 'http://localhost:10200/font-size.html',
urlProvider: 'network',
line: 10,
column: 55,
},
selector: '.small-2',
fontSize: '11px',
},
{
source: {
url: 'font-size-inline-magic.css',
urlProvider: 'comment',
line: 2,
column: 14,
},
selector: '.small-3',
fontSize: '6px',
},
{
source: {
url: 'font-size-styles-magic.css',
urlProvider: 'comment',
line: 2,
column: 10,
},
selector: '.small-4',
fontSize: '6px',
},
{
source: {type: 'code', value: 'User Agent Stylesheet'},
selector: 'h6',
fontSize: '10.72px',
},
{
source: {type: 'url', value: 'http://localhost:10200/font-size.html'},
selector: {
type: 'node',
selector: 'body',
snippet: '<font size="1">',
},
fontSize: '10px',
},
{
source: {type: 'url', value: 'http://localhost:10200/font-size.html'},
selector: {
type: 'node',
selector: 'font',
snippet: '<b>',
},
fontSize: '10px',
},
{
source: {type: 'url', value: 'http://localhost:10200/font-size.html'},
selector: {
type: 'node',
selector: 'div',
snippet: '<p style="font-size:10px">',
},
fontSize: '10px',
},
{
source: {type: 'code', value: 'Legible text'},
selector: '',
fontSize: '≥ 12px',
},
],
},
},
},
},
};

export default {
id: 'font-size',
expectations,
};

21 changes: 0 additions & 21 deletions cli/test/smokehouse/test-definitions/seo-failing.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ const expectations = {
requestedUrl: BASE_URL + 'seo-failure-cases.html?' + failureHeaders,
finalDisplayedUrl: BASE_URL + 'seo-failure-cases.html?' + failureHeaders,
audits: {
'viewport': {
score: 0,
details: {
type: 'debugdata',
viewportContent: 'invalid-content=should_have_looked_it_up',
},
},
'document-title': {
score: 0,
},
Expand All @@ -60,11 +53,6 @@ const expectations = {
'http-status-code': {
score: 1,
},
'font-size': {
score: 0,
explanation:
'Text is illegible because there\'s no viewport meta tag optimized for mobile screens.',
},
'crawlable-anchors': {
score: 0,
details: {
Expand All @@ -73,15 +61,6 @@ const expectations = {
},
},
},
'link-text': {
score: 0,
displayValue: '4 links found',
details: {
items: {
length: 4,
},
},
},
'is-crawlable': {
score: 0,
details: {
Expand Down
Loading
Loading