Skip to content

Commit 1b4748a

Browse files
authoredFeb 18, 2022
tests(devtools): navigation web test (#13673)
1 parent e3fdffc commit 1b4748a

File tree

2 files changed

+711
-0
lines changed

2 files changed

+711
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,612 @@
1+
Tests that navigation mode works correctly.
2+
3+
4+
========== Lighthouse Start Audit State ==========
5+
[x] Performance
6+
[x] Progressive Web App
7+
[x] Best practices
8+
[x] Accessibility
9+
[x] SEO
10+
[x] Publisher Ads
11+
[ ] Legacy navigation
12+
[x] Clear storage
13+
[x] Simulated throttling
14+
Generate report: enabled visible
15+
16+
=============== Lighthouse Status Updates ===============
17+
Loading…
18+
Initialize config
19+
Resolve artifact definitions
20+
Resolve navigation definitions
21+
Gather phase
22+
Connecting to browser
23+
Navigating to about:blank
24+
Benchmarking machine
25+
Getting browser version
26+
Preparing target for navigation mode
27+
Navigating to about:blank
28+
Preparing target for navigation
29+
Cleaning origin data
30+
Cleaning browser cache
31+
Preparing network conditions
32+
Navigating to http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-basic.html
33+
Computing artifact: NetworkRecords$M
34+
Get webapp installability errors
35+
Getting browser version
36+
Collect stacks
37+
Computing artifact: ProcessedTrace$f
38+
Computing artifact: ProcessedNavigation$7
39+
Get webapp manifest
40+
Audit phase
41+
Analyzing and running audits...
42+
Auditing: Uses HTTPS
43+
Auditing: Registers a service worker that controls page and `start_url`
44+
Auditing: Has a `<meta name="viewport">` tag with `width` or `initial-scale`
45+
Computing artifact: ViewportMeta
46+
Auditing: First Contentful Paint
47+
Computing artifact: FirstContentfulPaint$3
48+
Computing artifact: LanternFirstContentfulPaint$6
49+
Computing artifact: PageDependencyGraph$a
50+
Computing artifact: LoadSimulator$a
51+
Computing artifact: NetworkAnalysis$1
52+
Auditing: Largest Contentful Paint
53+
Computing artifact: LargestContentfulPaint$2
54+
Computing artifact: LanternLargestContentfulPaint$1
55+
Auditing: First Meaningful Paint
56+
Computing artifact: FirstMeaningfulPaint$2
57+
Computing artifact: LanternFirstMeaningfulPaint$2
58+
Auditing: Speed Index
59+
Computing artifact: SpeedIndex$2
60+
Computing artifact: LanternSpeedIndex$2
61+
Computing artifact: Speedline$4
62+
Auditing: Screenshot Thumbnails
63+
Auditing: Final Screenshot
64+
Computing artifact: Screenshots$1
65+
Auditing: Total Blocking Time
66+
Computing artifact: TotalBlockingTime$2
67+
Computing artifact: LanternTotalBlockingTime$1
68+
Computing artifact: LanternInteractive$4
69+
Auditing: Max Potential First Input Delay
70+
Computing artifact: MaxPotentialFID$2
71+
Computing artifact: LanternMaxPotentialFID$1
72+
Auditing: Cumulative Layout Shift
73+
Computing artifact: CumulativeLayoutShift$2
74+
Auditing: No browser errors logged to the console
75+
Computing artifact: JSBundles
76+
Auditing: Initial server response time was short
77+
Computing artifact: MainResource$g
78+
Auditing: Time to Interactive
79+
Computing artifact: Interactive$4
80+
Auditing: User Timing marks and measures
81+
Computing artifact: UserTimings$1
82+
Auditing: Avoid chaining critical requests
83+
Computing artifact: CriticalRequestChains$2
84+
Auditing: Avoid multiple page redirects
85+
Auditing: Web app manifest and service worker meet the installability requirements
86+
Computing artifact: ManifestValues$4
87+
Auditing: Provides a valid `apple-touch-icon`
88+
Auditing: Configured for a custom splash screen
89+
Auditing: Sets a theme color for the address bar.
90+
Auditing: Manifest has a maskable icon
91+
Auditing: Content is sized correctly for the viewport
92+
Auditing: Displays images with correct aspect ratio
93+
Auditing: Serves images with appropriate resolution
94+
Auditing: Fonts with `font-display: optional` are preloaded
95+
Auditing: Avoids deprecated APIs
96+
Auditing: Minimizes main-thread work
97+
Computing artifact: MainThreadTasks$7
98+
Auditing: JavaScript execution time
99+
Auditing: Preload key requests
100+
Auditing: Preconnect to required origins
101+
Auditing: All text remains visible during webfont loads
102+
Auditing: Diagnostics
103+
Auditing: Network Requests
104+
Auditing: Network Round Trip Times
105+
Auditing: Server Backend Latencies
106+
Auditing: Tasks
107+
Auditing: Metrics
108+
Computing artifact: TimingSummary$1
109+
Auditing: Performance budget
110+
Computing artifact: ResourceSummary$2
111+
Auditing: Timing budget
112+
Auditing: Keep request counts low and transfer sizes small
113+
Auditing: Minimize third-party usage
114+
Auditing: Lazy load third-party resources with facades
115+
Auditing: Largest Contentful Paint element
116+
Auditing: Largest Contentful Paint image was not lazily loaded
117+
Auditing: Avoid large layout shifts
118+
Auditing: Avoid long main-thread tasks
119+
Auditing: Avoids `unload` event listeners
120+
Auditing: Avoid non-composited animations
121+
Auditing: Image elements have explicit `width` and `height`
122+
Auditing: Page has valid source maps
123+
Auditing: Preload Largest Contentful Paint image
124+
Auditing: Ensure CSP is effective against XSS attacks
125+
Auditing: Full-page screenshot
126+
Auditing: Script Treemap Data
127+
Computing artifact: ModuleDuplication$2
128+
Auditing: Site works cross-browser
129+
Auditing: Page transitions don't feel like they block on the network
130+
Auditing: Each page has a URL
131+
Auditing: `[accesskey]` values are unique
132+
Auditing: `[aria-*]` attributes match their roles
133+
Auditing: `button`, `link`, and `menuitem` elements have accessible names
134+
Auditing: `[aria-hidden="true"]` is not present on the document `<body>`
135+
Auditing: `[aria-hidden="true"]` elements do not contain focusable descendents
136+
Auditing: ARIA input fields have accessible names
137+
Auditing: ARIA `meter` elements have accessible names
138+
Auditing: ARIA `progressbar` elements have accessible names
139+
Auditing: `[role]`s have all required `[aria-*]` attributes
140+
Auditing: Elements with an ARIA `[role]` that require children to contain a specific `[role]` have all required children.
141+
Auditing: `[role]`s are contained by their required parent element
142+
Auditing: `[role]` values are valid
143+
Auditing: ARIA toggle fields have accessible names
144+
Auditing: ARIA `tooltip` elements have accessible names
145+
Auditing: ARIA `treeitem` elements have accessible names
146+
Auditing: `[aria-*]` attributes have valid values
147+
Auditing: `[aria-*]` attributes are valid and not misspelled
148+
Auditing: Buttons have an accessible name
149+
Auditing: The page contains a heading, skip link, or landmark region
150+
Auditing: Background and foreground colors have a sufficient contrast ratio
151+
Auditing: `<dl>`'s contain only properly-ordered `<dt>` and `<dd>` groups, `<script>`, `<template>` or `<div>` elements.
152+
Auditing: Definition list items are wrapped in `<dl>` elements
153+
Auditing: Document has a `<title>` element
154+
Auditing: `[id]` attributes on active, focusable elements are unique
155+
Auditing: ARIA IDs are unique
156+
Auditing: No form fields have multiple labels
157+
Auditing: `<frame>` or `<iframe>` elements have a title
158+
Auditing: Heading elements appear in a sequentially-descending order
159+
Auditing: `<html>` element has a `[lang]` attribute
160+
Auditing: `<html>` element has a valid value for its `[lang]` attribute
161+
Auditing: Image elements have `[alt]` attributes
162+
Auditing: `<input type="image">` elements have `[alt]` text
163+
Auditing: Form elements have associated labels
164+
Auditing: Links have a discernible name
165+
Auditing: Lists contain only `<li>` elements and script supporting elements (`<script>` and `<template>`).
166+
Auditing: List items (`<li>`) are contained within `<ul>` or `<ol>` parent elements
167+
Auditing: The document does not use `<meta http-equiv="refresh">`
168+
Auditing: `[user-scalable="no"]` is not used in the `<meta name="viewport">` element and the `[maximum-scale]` attribute is not less than 5.
169+
Auditing: `<object>` elements have alternate text
170+
Auditing: No element has a `[tabindex]` value greater than 0
171+
Auditing: Cells in a `<table>` element that use the `[headers]` attribute refer to table cells within the same table.
172+
Auditing: `<th>` elements and elements with `[role="columnheader"/"rowheader"]` have data cells they describe.
173+
Auditing: `[lang]` attributes have a valid value
174+
Auditing: `<video>` elements contain a `<track>` element with `[kind="captions"]`
175+
Auditing: Custom controls have associated labels
176+
Auditing: Custom controls have ARIA roles
177+
Auditing: User focus is not accidentally trapped in a region
178+
Auditing: Interactive controls are keyboard focusable
179+
Auditing: Interactive elements indicate their purpose and state
180+
Auditing: The page has a logical tab order
181+
Auditing: The user's focus is directed to new content added to the page
182+
Auditing: Offscreen content is hidden from assistive technology
183+
Auditing: HTML5 landmark elements are used to improve navigation
184+
Auditing: Visual order on the page follows DOM order
185+
Auditing: Uses efficient cache policy on static assets
186+
Auditing: Avoids enormous network payloads
187+
Auditing: Defer offscreen images
188+
Auditing: Eliminate render-blocking resources
189+
Computing artifact: UnusedCSS$3
190+
Computing artifact: FirstContentfulPaint$3
191+
Auditing: Minify CSS
192+
Auditing: Minify JavaScript
193+
Auditing: Reduce unused CSS
194+
Auditing: Reduce unused JavaScript
195+
Auditing: Serve images in next-gen formats
196+
Auditing: Efficiently encode images
197+
Auditing: Enable text compression
198+
Auditing: Properly size images
199+
Computing artifact: ImageRecords$1
200+
Auditing: Use video formats for animated content
201+
Auditing: Remove duplicate modules in JavaScript bundles
202+
Auditing: Avoid serving legacy JavaScript to modern browsers
203+
Auditing: Page has the HTML doctype
204+
Auditing: Properly defines charset
205+
Auditing: Avoids an excessive DOM size
206+
Auditing: Avoids requesting the geolocation permission on page load
207+
Auditing: No issues in the `Issues` panel in Chrome Devtools
208+
Auditing: Avoids `document.write()`
209+
Auditing: Avoids front-end JavaScript libraries with known security vulnerabilities
210+
Auditing: Detected JavaScript libraries
211+
Auditing: Avoids requesting the notification permission on page load
212+
Auditing: Allows users to paste into password fields
213+
Auditing: Use HTTP/2
214+
Auditing: Uses passive listeners to improve scrolling performance
215+
Auditing: Document has a meta description
216+
Auditing: Page has successful HTTP status code
217+
Auditing: Document uses legible font sizes
218+
Auditing: Links have descriptive text
219+
Auditing: Links are crawlable
220+
Auditing: Page isn’t blocked from indexing
221+
Auditing: robots.txt is valid
222+
Auditing: Tap targets are sized appropriately
223+
Auditing: Document has a valid `hreflang`
224+
Auditing: Document avoids plugins
225+
Auditing: Document has a valid `rel=canonical`
226+
Auditing: Structured data is valid
227+
Auditing: No long tasks blocking ad-related network requests
228+
Computing artifact: LongTasks$2
229+
Auditing: Minimal render-blocking resources found
230+
Auditing: Ad request waterfall
231+
Auditing: First bid request time
232+
Computing artifact: BidRequestTime
233+
Computing artifact: LanternBidRequestTime
234+
Auditing: First ad request time
235+
Computing artifact: AdRequestTime$1
236+
Computing artifact: LanternAdRequestTime
237+
Auditing: No ad found at the very top of the viewport
238+
Auditing: Few or no ads loaded outside viewport
239+
Auditing: Ad tag is loaded asynchronously
240+
Auditing: Ads not blocked by load events
241+
Computing artifact: TraceOfTab$1
242+
Auditing: No bottleneck requests found
243+
Auditing: No duplicate tags found
244+
Auditing: Latency of first ad render
245+
Computing artifact: AdRenderTime
246+
Computing artifact: LanternAdRenderTime
247+
Auditing: GPT and bids loaded in parallel
248+
Auditing: GPT tag is loaded from an official source
249+
Auditing: Ad tag is loaded over HTTPS
250+
Auditing: Ad scripts are loaded statically
251+
Auditing: Header bidding is parallelized
252+
Auditing: Tag load time
253+
Computing artifact: TagLoadTime$1
254+
Computing artifact: LanternTagLoadTime
255+
Auditing: Ads to page-height ratio is within recommended range
256+
Auditing: Cumulative ad shift
257+
Auditing: Deprecated GPT API Usage
258+
Auditing: GPT Errors
259+
Auditing: Total ad JS blocking time
260+
Generating results...
261+
262+
=============== Lighthouse Results ===============
263+
URL: http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-basic.html
264+
Version: 9.4.0
265+
ViewportDimensions: {
266+
"innerWidth": 980,
267+
"innerHeight": 1743,
268+
"outerWidth": 360,
269+
"outerHeight": 640,
270+
"devicePixelRatio": 3
271+
}
272+
273+
274+
accesskeys: notApplicable
275+
ad-blocking-tasks: notApplicable
276+
ad-render-blocking-resources: notApplicable
277+
ad-request-critical-path: notApplicable
278+
ad-request-from-page-start: notApplicable
279+
ad-top-of-viewport: notApplicable
280+
ads-in-viewport: notApplicable
281+
apple-touch-icon: fail
282+
aria-allowed-attr: notApplicable
283+
aria-command-name: notApplicable
284+
aria-hidden-body: pass
285+
aria-hidden-focus: notApplicable
286+
aria-input-field-name: notApplicable
287+
aria-meter-name: notApplicable
288+
aria-progressbar-name: notApplicable
289+
aria-required-attr: notApplicable
290+
aria-required-children: notApplicable
291+
aria-required-parent: notApplicable
292+
aria-roles: notApplicable
293+
aria-toggle-field-name: notApplicable
294+
aria-tooltip-name: notApplicable
295+
aria-treeitem-name: notApplicable
296+
aria-valid-attr: notApplicable
297+
aria-valid-attr-value: notApplicable
298+
async-ad-tags: notApplicable
299+
bid-request-from-page-start: notApplicable
300+
blocking-load-events: notApplicable
301+
bootup-time: flaky
302+
bottleneck-requests: notApplicable
303+
button-name: notApplicable
304+
bypass: notApplicable
305+
canonical: notApplicable
306+
charset: pass
307+
color-contrast: pass
308+
content-width: fail
309+
crawlable-anchors: pass
310+
critical-request-chains: informative
311+
csp-xss: informative
312+
cumulative-ad-shift: notApplicable
313+
cumulative-layout-shift: numeric
314+
custom-controls-labels: manual
315+
custom-controls-roles: manual
316+
definition-list: notApplicable
317+
deprecated-gpt-api-usage: notApplicable
318+
deprecations: pass
319+
diagnostics: informative
320+
dlitem: notApplicable
321+
doctype: pass
322+
document-title: fail
323+
dom-size: numeric
324+
duplicate-id-active: notApplicable
325+
duplicate-id-aria: notApplicable
326+
duplicate-tags: notApplicable
327+
duplicated-javascript: numeric
328+
efficient-animated-content: flaky
329+
errors-in-console: pass
330+
final-screenshot: ERROR Chrome didn't collect any screenshots during the page load. Please make sure there is content visible on the page, and then try re-running Lighthouse. (NO_SCREENSHOTS)
331+
first-ad-render: notApplicable
332+
first-contentful-paint: flaky
333+
first-meaningful-paint: flaky
334+
focus-traps: manual
335+
focusable-controls: manual
336+
font-display: pass
337+
font-size: fail
338+
form-field-multiple-labels: notApplicable
339+
frame-title: notApplicable
340+
full-page-screenshot: informative
341+
geolocation-on-start: pass
342+
gpt-bids-parallel: notApplicable
343+
gpt-errors-overall: notApplicable
344+
heading-order: notApplicable
345+
hreflang: pass
346+
html-has-lang: fail
347+
html-lang-valid: notApplicable
348+
http-status-code: pass
349+
image-alt: notApplicable
350+
image-aspect-ratio: pass
351+
image-size-responsive: pass
352+
input-image-alt: notApplicable
353+
inspector-issues: pass
354+
installable-manifest: fail
355+
interactive: flaky
356+
interactive-element-affordance: manual
357+
is-crawlable: pass
358+
is-on-https: pass
359+
js-libraries: notApplicable
360+
label: notApplicable
361+
largest-contentful-paint: numeric
362+
largest-contentful-paint-element: informative
363+
layout-shift-elements: notApplicable
364+
lcp-lazy-loaded: notApplicable
365+
legacy-javascript: numeric
366+
link-name: notApplicable
367+
link-text: pass
368+
list: notApplicable
369+
listitem: notApplicable
370+
loads-ad-tag-over-https: notApplicable
371+
loads-gpt-from-official-source: notApplicable
372+
logical-tab-order: manual
373+
long-tasks: flaky
374+
main-thread-tasks: informative
375+
mainthread-work-breakdown: numeric
376+
managed-focus: manual
377+
maskable-icon: fail
378+
max-potential-fid: numeric
379+
meta-description: fail
380+
meta-refresh: notApplicable
381+
meta-viewport: notApplicable
382+
metrics: flaky
383+
modern-image-formats: flaky
384+
network-requests: informative
385+
network-rtt: informative
386+
network-server-latency: informative
387+
no-document-write: pass
388+
no-unload-listeners: pass
389+
no-vulnerable-libraries: pass
390+
non-composited-animations: notApplicable
391+
notification-on-start: pass
392+
object-alt: notApplicable
393+
offscreen-content-hidden: manual
394+
offscreen-images: flaky
395+
password-inputs-can-be-pasted-into: pass
396+
performance-budget: notApplicable
397+
plugins: pass
398+
preload-fonts: notApplicable
399+
preload-lcp-image: numeric
400+
pwa-cross-browser: manual
401+
pwa-each-page-has-url: manual
402+
pwa-page-transitions: manual
403+
redirects: flaky
404+
render-blocking-resources: flaky
405+
resource-summary: informative
406+
robots-txt: notApplicable
407+
screenshot-thumbnails: flaky
408+
script-injected-tags: notApplicable
409+
script-treemap-data: informative
410+
serial-header-bidding: notApplicable
411+
server-response-time: pass
412+
service-worker: fail
413+
speed-index: flaky
414+
splash-screen: fail
415+
structured-data: manual
416+
tabindex: notApplicable
417+
tag-load-time: notApplicable
418+
tap-targets: fail
419+
td-headers-attr: notApplicable
420+
th-has-data-cells: notApplicable
421+
themed-omnibox: fail
422+
third-party-facades: notApplicable
423+
third-party-summary: notApplicable
424+
timing-budget: ERROR Chrome didn't collect any screenshots during the page load. Please make sure there is content visible on the page, and then try re-running Lighthouse. (NO_SCREENSHOTS)
425+
total-ad-blocking-time: notApplicable
426+
total-blocking-time: numeric
427+
total-byte-weight: numeric
428+
unminified-css: flaky
429+
unminified-javascript: flaky
430+
unsized-images: notApplicable
431+
unused-css-rules: flaky
432+
unused-javascript: numeric
433+
use-landmarks: manual
434+
user-timings: flaky
435+
uses-http2: numeric
436+
uses-long-cache-ttl: numeric
437+
uses-optimized-images: flaky
438+
uses-passive-event-listeners: pass
439+
uses-rel-preconnect: numeric
440+
uses-rel-preload: flaky
441+
uses-responsive-images: flaky
442+
uses-text-compression: flaky
443+
valid-lang: notApplicable
444+
valid-source-maps: pass
445+
video-caption: notApplicable
446+
viewport: fail
447+
viewport-ad-density: notApplicable
448+
visual-order-follows-dom: manual
449+
450+
# of .lh-audit divs: 159
451+
452+
.lh-audit divs:
453+
accesskeys
454+
ad-blocking-tasks
455+
ad-render-blocking-resources
456+
ad-request-critical-path
457+
ad-request-from-page-start
458+
ad-top-of-viewport
459+
ads-in-viewport
460+
apple-touch-icon
461+
aria-allowed-attr
462+
aria-command-name
463+
aria-hidden-body
464+
aria-hidden-focus
465+
aria-input-field-name
466+
aria-meter-name
467+
aria-progressbar-name
468+
aria-required-attr
469+
aria-required-children
470+
aria-required-parent
471+
aria-roles
472+
aria-toggle-field-name
473+
aria-tooltip-name
474+
aria-treeitem-name
475+
aria-valid-attr
476+
aria-valid-attr-value
477+
async-ad-tags
478+
bid-request-from-page-start
479+
blocking-load-events
480+
bootup-time
481+
bottleneck-requests
482+
button-name
483+
bypass
484+
canonical
485+
charset
486+
color-contrast
487+
content-width
488+
crawlable-anchors
489+
critical-request-chains
490+
csp-xss
491+
cumulative-ad-shift
492+
custom-controls-labels
493+
custom-controls-roles
494+
definition-list
495+
deprecated-gpt-api-usage
496+
deprecations
497+
dlitem
498+
doctype
499+
document-title
500+
document-title
501+
dom-size
502+
duplicate-id-active
503+
duplicate-id-aria
504+
duplicate-tags
505+
duplicated-javascript
506+
efficient-animated-content
507+
errors-in-console
508+
first-ad-render
509+
focus-traps
510+
focusable-controls
511+
font-display
512+
font-size
513+
form-field-multiple-labels
514+
frame-title
515+
geolocation-on-start
516+
gpt-bids-parallel
517+
gpt-errors-overall
518+
heading-order
519+
hreflang
520+
html-has-lang
521+
html-lang-valid
522+
http-status-code
523+
image-alt
524+
image-alt
525+
image-aspect-ratio
526+
image-size-responsive
527+
input-image-alt
528+
inspector-issues
529+
installable-manifest
530+
interactive-element-affordance
531+
is-crawlable
532+
is-on-https
533+
js-libraries
534+
label
535+
largest-contentful-paint-element
536+
layout-shift-elements
537+
lcp-lazy-loaded
538+
legacy-javascript
539+
link-name
540+
link-text
541+
list
542+
listitem
543+
loads-ad-tag-over-https
544+
loads-gpt-from-official-source
545+
logical-tab-order
546+
long-tasks
547+
mainthread-work-breakdown
548+
managed-focus
549+
maskable-icon
550+
meta-description
551+
meta-refresh
552+
meta-viewport
553+
modern-image-formats
554+
no-document-write
555+
no-unload-listeners
556+
no-vulnerable-libraries
557+
non-composited-animations
558+
notification-on-start
559+
object-alt
560+
offscreen-content-hidden
561+
offscreen-images
562+
password-inputs-can-be-pasted-into
563+
plugins
564+
preload-fonts
565+
preload-lcp-image
566+
pwa-cross-browser
567+
pwa-each-page-has-url
568+
pwa-page-transitions
569+
redirects
570+
render-blocking-resources
571+
resource-summary
572+
robots-txt
573+
script-injected-tags
574+
serial-header-bidding
575+
server-response-time
576+
service-worker
577+
splash-screen
578+
structured-data
579+
tabindex
580+
tag-load-time
581+
tap-targets
582+
td-headers-attr
583+
th-has-data-cells
584+
themed-omnibox
585+
third-party-facades
586+
third-party-summary
587+
total-ad-blocking-time
588+
total-byte-weight
589+
unminified-css
590+
unminified-javascript
591+
unsized-images
592+
unused-css-rules
593+
unused-javascript
594+
use-landmarks
595+
user-timings
596+
uses-http2
597+
uses-long-cache-ttl
598+
uses-optimized-images
599+
uses-passive-event-listeners
600+
uses-rel-preconnect
601+
uses-rel-preload
602+
uses-responsive-images
603+
uses-text-compression
604+
valid-lang
605+
valid-source-maps
606+
video-caption
607+
viewport
608+
viewport
609+
viewport
610+
viewport-ad-density
611+
visual-order-follows-dom
612+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright 2022 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
(async function() {
6+
// screenshots in content shell are flaky and NO_NAVSTART occurs on bots way more frequently than local
7+
// ignore the results of the trace-dependent audits, just make sure they ran
8+
const FLAKY_AUDITS = [
9+
// metrics
10+
'first-contentful-paint',
11+
'first-meaningful-paint',
12+
'interactive',
13+
'speed-index',
14+
'metrics',
15+
'screenshot-thumbnails',
16+
// misc trace-based audits
17+
'long-tasks',
18+
'user-timings',
19+
'bootup-time',
20+
// opportunities
21+
'efficient-animated-content',
22+
'offscreen-images',
23+
'redirects',
24+
'render-blocking-resources',
25+
'unminified-css',
26+
'unminified-javascript',
27+
'unused-css-rules',
28+
'uses-optimized-images',
29+
'uses-rel-preload',
30+
'uses-responsive-images',
31+
'uses-text-compression',
32+
'modern-image-formats',
33+
];
34+
35+
TestRunner.addResult('Tests that navigation mode works correctly.\n');
36+
await TestRunner.navigatePromise('resources/lighthouse-basic.html');
37+
38+
await TestRunner.loadTestModule('lighthouse_test_runner');
39+
await TestRunner.showPanel('lighthouse');
40+
41+
// Enable Publisher Ads.
42+
const containerElement = LighthouseTestRunner.getContainerElement();
43+
const checkboxes = containerElement.querySelectorAll('.checkbox');
44+
for (const checkbox of checkboxes) {
45+
if (checkbox.textElement.textContent === 'Publisher Ads') {
46+
checkbox.checkboxElement.click();
47+
}
48+
}
49+
50+
// Enable FR navigation.
51+
containerElement.querySelector('.lighthouse-settings-pane > div').shadowRoot
52+
.querySelectorAll('span')[0].shadowRoot
53+
.querySelector('input').click();
54+
55+
LighthouseTestRunner.dumpStartAuditState();
56+
57+
TestRunner.addResult('\n=============== Lighthouse Status Updates ===============');
58+
LighthouseTestRunner.addStatusListener(msg => TestRunner.addResult(msg));
59+
LighthouseTestRunner.getRunButton().click();
60+
61+
const {artifacts, lhr} = await LighthouseTestRunner.waitForResults();
62+
TestRunner.addResult('\n=============== Lighthouse Results ===============');
63+
TestRunner.addResult(`URL: ${lhr.finalUrl}`);
64+
TestRunner.addResult(`Version: ${lhr.lighthouseVersion}`);
65+
TestRunner.addResult(`ViewportDimensions: ${JSON.stringify(artifacts.ViewportDimensions, null, 2)}`);
66+
TestRunner.addResult('\n');
67+
68+
Object.keys(lhr.audits).sort().forEach(auditName => {
69+
const audit = lhr.audits[auditName];
70+
71+
if (FLAKY_AUDITS.includes(auditName)) {
72+
TestRunner.addResult(`${auditName}: flaky`);
73+
} else if (audit.scoreDisplayMode === 'error') {
74+
TestRunner.addResult(`${auditName}: ERROR ${audit.errorMessage}`);
75+
} else if (audit.scoreDisplayMode === 'binary') {
76+
TestRunner.addResult(`${auditName}: ${audit.score ? 'pass' : 'fail'}`);
77+
} else {
78+
TestRunner.addResult(`${auditName}: ${audit.scoreDisplayMode}`);
79+
}
80+
});
81+
82+
const resultsElement = LighthouseTestRunner.getResultsElement();
83+
const auditElements = [...resultsElement.querySelectorAll('.lh-audit')];
84+
const auditElementNames = auditElements.map(e => e.id).sort((a, b) => a.localeCompare(b));
85+
TestRunner.addResult(`\n# of .lh-audit divs: ${auditElements.length}`);
86+
TestRunner.addResult(`\n.lh-audit divs:\n${auditElementNames.join('\n')}`);
87+
88+
// Ensure duplicate events are not recieved.
89+
// See https://github.com/GoogleChrome/lighthouse/issues/11415
90+
const devtoolsLog = artifacts.devtoolsLogs.defaultPass;
91+
const networkResponseRecievedEvents = devtoolsLog.filter(
92+
log => log.method === 'Network.responseReceived' && log.params.response.url.endsWith('lighthouse-basic.html'));
93+
if (networkResponseRecievedEvents.length !== 1) {
94+
TestRunner.addResult(`ERROR: Network.responseReceived events for main resource; expected 1, got ${
95+
networkResponseRecievedEvents.length}`);
96+
}
97+
98+
TestRunner.completeTest();
99+
})();

0 commit comments

Comments
 (0)
Please sign in to comment.