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

update to lighthouse 10.1.1 #395

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
steps:
- name: git clone
uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x
- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn lint

Expand All @@ -23,10 +23,10 @@ jobs:
steps:
- name: git clone
uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x
- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn type-check

Expand All @@ -36,10 +36,10 @@ jobs:
steps:
- name: git clone
uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x
- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn test

Expand All @@ -49,10 +49,10 @@ jobs:
steps:
- name: git clone
uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x
- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: sudo apt-get install xvfb
- name: Run smoke tests
Expand All @@ -64,14 +64,14 @@ jobs:
steps:
- name: git clone
uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x
- name: npm install
run: npm install
- name: Install Lighthouse CI
run: npm install -g @lhci/cli@0.6.x
run: npm install -g @lhci/cli@0.12.x
- name: Run Lighthouse CI
run: lhci autorun
env:
Expand Down
22 changes: 14 additions & 8 deletions lighthouse-plugin-publisher-ads/audits/ad-blocking-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
const HEADINGS = [
{
key: 'script',
itemType: 'url',
text: str_(UIStrings.columnScript),
valueType: 'url',
label: str_(UIStrings.columnScript),
},
{
key: 'startTime',
itemType: 'ms',
text: str_(UIStrings.columnStartTime),
valueType: 'ms',
label: str_(UIStrings.columnStartTime),
granularity: 1,
},
{
key: 'duration',
itemType: 'ms',
text: str_(UIStrings.columnDuration),
valueType: 'ms',
label: str_(UIStrings.columnDuration),
granularity: 1,
},
];
Expand All @@ -78,7 +78,7 @@ class AdBlockingTasks extends Audit {
title: str_(UIStrings.title),
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
requiredArtifacts: ['traces', 'devtoolsLogs'],
requiredArtifacts: ['traces', 'devtoolsLogs', 'URL', 'GatherContext'],
};
}

Expand All @@ -97,7 +97,13 @@ class AdBlockingTasks extends Audit {
context.settings.throttlingMethod == 'simulate' ? 200 : 100;
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricData = {trace, devtoolsLog, settings: context.settings};
const metricData = {
trace,
devtoolsLog,
settings: context.settings,
URL: artifacts.URL,
gatherContext: artifacts.GatherContext,
};
let longTasks = [];
try {
longTasks = await LongTasks.request(metricData, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ const THRESHOLD_MS = 100;
const HEADINGS = [
{
key: 'url',
itemType: 'url',
text: str_(UIStrings.columnUrl),
valueType: 'url',
label: str_(UIStrings.columnUrl),
},
{
key: 'startTime',
itemType: 'ms',
text: str_(UIStrings.columnStartTime),
valueType: 'ms',
label: str_(UIStrings.columnStartTime),
granularity: 1,
},
{
key: 'duration',
itemType: 'ms',
text: str_(UIStrings.columnDuration),
valueType: 'ms',
label: str_(UIStrings.columnDuration),
granularity: 1,
},
];
Expand All @@ -82,7 +82,7 @@ class AdRenderBlockingResources extends Audit {
scoreDisplayMode: 'binary',
description: str_(UIStrings.description),
requiredArtifacts:
['LinkElements', 'ScriptElements', 'devtoolsLogs', 'traces'],
['LinkElements', 'ScriptElements', 'devtoolsLogs', 'traces', 'URL'],
};
}

Expand All @@ -102,7 +102,7 @@ class AdRenderBlockingResources extends Audit {

/** @type {Map<NetworkRequest, NodeTiming>} */
const timingsByRecord =
await getTimingsByRecord(trace, devtoolsLog, context);
await getTimingsByRecord(trace, devtoolsLog, artifacts.URL, context);

// NOTE(warrengm): Ideally we would key be requestId here but LinkElements
// don't have request IDs.
Expand All @@ -125,7 +125,7 @@ class AdRenderBlockingResources extends Audit {
const blockingNetworkRecords = networkRecords
// Don't fail on sync resources loaded after the tag. This includes sync
// resources loaded inside of iframes.
.filter((r) => r.endTime < tag.startTime)
.filter((r) => r.networkEndTime < tag.networkRequestTime)
.filter((r) => r != tag.initiatorRequest)
// Sanity check to filter out duplicate requests which were async. If
// type != parser then the resource was dynamically added and is
Expand All @@ -147,11 +147,9 @@ class AdRenderBlockingResources extends Audit {
const blockingStart = Math.min(...startTimes);
const blockingEnd = Math.min(Math.max(...endTimes), tagTime.startTime);
const opportunity = blockingEnd - blockingStart;
let displayValue = '';
if (tableView.length > 0 && opportunity > 0) {
displayValue = str_(
UIStrings.failureDisplayValue, {timeInMs: opportunity});
}
const displayValue = tableView.length > 0 && opportunity > 0 ?
str_(UIStrings.failureDisplayValue, {timeInMs: opportunity}) :
'';

const failed = tableView.length > 0 && opportunity > THRESHOLD_MS;
return {
Expand All @@ -160,7 +158,9 @@ class AdRenderBlockingResources extends Audit {
numericUnit: 'unitless',
displayValue,
details: {
// @ts-expect-error
opportunity,
// @ts-expect-error
...AdRenderBlockingResources.makeTableDetails(HEADINGS, tableView),
},
};
Expand Down
23 changes: 13 additions & 10 deletions lighthouse-plugin-publisher-ads/audits/ad-request-critical-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
const HEADINGS = [
{
key: 'nameOrTld',
itemType: 'text',
text: str_(UIStrings.columnType),
valueType: 'text',
label: str_(UIStrings.columnType),
},
{
key: 'url',
itemType: 'url',
text: str_(UIStrings.columnUrl),
valueType: 'url',
label: str_(UIStrings.columnUrl),
},
{
key: 'startTime',
itemType: 'ms',
text: str_(UIStrings.columnStartTime),
valueType: 'ms',
label: str_(UIStrings.columnStartTime),
granularity: 1,
},
{
key: 'endTime',
itemType: 'ms',
text: str_(UIStrings.columnEndTime),
valueType: 'ms',
label: str_(UIStrings.columnEndTime),
granularity: 1,
},
];
Expand Down Expand Up @@ -127,7 +127,7 @@ class AdRequestCriticalPath extends Audit {
failureTitle: str_(UIStrings.failureTitle),
description: str_(UIStrings.description),
scoreDisplayMode: 'informative',
requiredArtifacts: ['devtoolsLogs', 'traces'],
requiredArtifacts: ['devtoolsLogs', 'traces', 'URL'],
};
}

Expand All @@ -141,7 +141,8 @@ class AdRequestCriticalPath extends Audit {
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];

const tableView =
(await computeAdRequestWaterfall(trace, devtoolsLog, context))
// eslint-disable-next-line max-len
(await computeAdRequestWaterfall(trace, devtoolsLog, artifacts.URL, context))
.filter((r) => r.startTime > 0 && r.startTime < r.endTime);
if (!tableView.length) {
return auditNotApplicable.NoAds;
Expand All @@ -163,10 +164,12 @@ class AdRequestCriticalPath extends Audit {
score: failed ? 0 : 1,
displayValue: str_(UIStrings.displayValue, {serialResources: depth}),
details: {
// @ts-expect-error
size: tableView.length,
depth,
maxIdleTime,
totalIdleTime,
// @ts-expect-error
...AdRequestCriticalPath.makeTableDetails(HEADINGS, tableView),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AdRequestFromPageStart extends Audit {
description: str_(UIStrings.description),
// @ts-ignore
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['devtoolsLogs', 'traces'],
requiredArtifacts: ['devtoolsLogs', 'traces', 'URL', 'GatherContext'],
};
}
/**
Expand Down Expand Up @@ -76,7 +76,13 @@ class AdRequestFromPageStart extends Audit {
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricData = {trace, devtoolsLog, settings: context.settings};
const metricData = {
trace,
devtoolsLog,
settings: context.settings,
URL: artifacts.URL,
gatherContext: artifacts.GatherContext,
};
const scoreOptions = context.options[
context.settings.throttlingMethod == 'provided' ?
'provided' :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AdRequestFromTagLoad extends Audit {
description: str_(UIStrings.description),
// @ts-ignore
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['devtoolsLogs', 'traces'],
requiredArtifacts: ['devtoolsLogs', 'traces', 'URL', 'GatherContext'],
};
}

Expand Down Expand Up @@ -77,7 +77,13 @@ class AdRequestFromTagLoad extends Audit {
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricData = {trace, devtoolsLog, settings: context.settings};
const metricData = {
trace,
devtoolsLog,
settings: context.settings,
URL: artifacts.URL,
gatherContext: artifacts.GatherContext,
};

const {timing: tagEndTime} =
await ComputedTagLoadTime.request(metricData, context);
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-plugin-publisher-ads/audits/ad-top-of-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ const SCROLL_PX_THRESHOLD = 100;
* @type {LH.Audit.Details.Table['headings']}
*/
const HEADINGS = [
{key: 'slot', itemType: 'text', text: str_(UIStrings.columnSlot)},
{key: 'slot', valueType: 'text', label: str_(UIStrings.columnSlot)},
];


/** @inheritDoc */
class AdTopOfViewport extends Audit {
/**
* @return {AuditMetadata}
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-plugin-publisher-ads/audits/ads-in-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
* @type {LH.Audit.Details.Table['headings']}
*/
const HEADINGS = [
{key: 'slot', itemType: 'text', text: str_(UIStrings.columnSlot)},
{key: 'slot', valueType: 'text', label: str_(UIStrings.columnSlot)},
];

/** @inheritDoc */
class AdsInViewport extends Audit {
/**
* @return {AuditMetadata}
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BidRequestFromPageStart extends Audit {
description: str_(UIStrings.description),
// @ts-ignore
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['devtoolsLogs', 'traces'],
requiredArtifacts: ['devtoolsLogs', 'traces', 'URL', 'GatherContext'],
};
}

Expand Down Expand Up @@ -77,7 +77,13 @@ class BidRequestFromPageStart extends Audit {
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricData = {trace, devtoolsLog, settings: context.settings};
const metricData = {
trace,
devtoolsLog,
settings: context.settings,
URL: artifacts.URL,
gatherContext: artifacts.GatherContext,
};
const scoreOptions = context.options[
context.settings.throttlingMethod == 'provided' ?
'provided' :
Expand Down
Loading