From 43042e187e015ef450203f5edeba1836ada4e1f9 Mon Sep 17 00:00:00 2001 From: Adam Raine <6752989+adamraine@users.noreply.github.com> Date: Mon, 27 Jul 2020 16:56:36 -0400 Subject: [PATCH] core: generalize TraceElements gatherer and add animated elements (#11138) * Add animation events to trace elements * Add trace elements to smoke test * Update smoke test to trace-elements * nits * lint * rename metric name * Fix smoke test * remove node id * lint * Add node test * nit * newline * fix tests * update sample * nits * old code cleanup * height too * set height manually * fix sample * Fix flaky score * switch to layout-shift * Correct element * switch to div * nit --- .../test/fixtures/perf/delayed-element.js | 3 +- .../test/fixtures/perf/trace-elements.html | 15 ++ .../test-definitions/perf/expectations.js | 62 ++++++ .../largest-contentful-paint-element.js | 4 +- .../audits/layout-shift-elements.js | 4 +- .../gather/gatherers/trace-elements.js | 88 +++++--- .../largest-contentful-paint-element-test.js | 2 +- .../test/audits/layout-shift-elements-test.js | 4 +- .../gather/gatherers/trace-elements-test.js | 195 ++++++++++++++++-- .../test/results/artifacts/artifacts.json | 10 +- types/artifacts.d.ts | 3 +- 11 files changed, 322 insertions(+), 68 deletions(-) diff --git a/lighthouse-cli/test/fixtures/perf/delayed-element.js b/lighthouse-cli/test/fixtures/perf/delayed-element.js index f267b9c57aec..4f472d5985e0 100644 --- a/lighthouse-cli/test/fixtures/perf/delayed-element.js +++ b/lighthouse-cli/test/fixtures/perf/delayed-element.js @@ -28,8 +28,9 @@ async function rerender(iterations) { setTimeout(() => { const imgEl = document.createElement('img'); imgEl.src = '../dobetterweb/lighthouse-480x318.jpg'; - const textEl = document.createElement('span'); + const textEl = document.createElement('div'); textEl.textContent = 'Sorry!'; + textEl.style.height = '18px' // this height can be flaky so we set it manually const top = document.getElementById('late-content'); top.appendChild(imgEl); top.appendChild(textEl); diff --git a/lighthouse-cli/test/fixtures/perf/trace-elements.html b/lighthouse-cli/test/fixtures/perf/trace-elements.html index 58ad27c20dd0..1624133ab13c 100644 --- a/lighthouse-cli/test/fixtures/perf/trace-elements.html +++ b/lighthouse-cli/test/fixtures/perf/trace-elements.html @@ -1,6 +1,21 @@ +
+" }, { - "metricName": "cumulative-layout-shift", + "traceEventType": "layout-shift", "devtoolsNodePath": "1,HTML,1,BODY,2,DIV,0,DIV,0,DIV,0,ARTICLE,1,DIV,3,H5", "selector": "div.blog-index > article > div.entry-content > h5", "nodeLabel": "Debugging Node.js with Chrome DevTools", "snippet": "
" }, { - "metricName": "cumulative-layout-shift", + "traceEventType": "layout-shift", "devtoolsNodePath": "1,HTML,1,BODY,2,DIV,0,DIV,0,DIV,0,ARTICLE,1,DIV,5,HR", "selector": "div.blog-index > article > div.entry-content > hr", "nodeLabel": "hr", "snippet": "