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(console-messages): use source-location #11899

Merged
merged 11 commits into from
Jan 14, 2021
Merged

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Dec 29, 2020

Change all audits that rely on ConsoleMessages to produce a source-location column, instead of url + "location" columns.

I also tweaked all the source-location columns to use the UIStrings.columnSource label.

Audits now using source-location and previously weren't:

  • deprecations
  • geolocation-on-start
  • no-document-write
  • notification-on-start
  • uses-passive-event-listeners
  • errors-in-console

Audits now using UIStrings.columnSource for source-location and previously weren't:

  • deprecations
  • no-unload-listeners

before

image

after

image

fixes #11761

(related #10930–this PR is low impact, only fixing the off-by-one line number + adding column, but once this other PR lands we'll also supercharge the URL here by using a source map for JS events)

// JS deprecations will have a stack trace.
// CSS deprecations only expose a line number.
const topCallFrame = log.stackTrace && log.stackTrace.callFrames[0];
const line = log.lineNumber || 0;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the call frames are now used in ConsoleMessages to set line/col, so we can just defer to that here now.

const consoleRows = artifacts.ConsoleMessages
.filter(item => item.level === 'error')
.map(item => {
return {
source: item.source,
description: item.text,
url: item.url,
sourceLocation: ConsoleMessages.createSourceLocation(item),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that source can't be used here, like every other audit.

@@ -81,14 +81,15 @@ class ErrorLogs extends Audit {
/** @type {AuditOptions} */
const auditOptions = context.options;

/** @type {Array<{source: string, description: string|undefined, url: string|undefined}>} */
/** @type {Array<{source: string, description: string|undefined, sourceLocation: LH.Audit.Details.SourceLocationValue|undefined}>} */
const consoleRows = artifacts.ConsoleMessages
.filter(item => item.level === 'error')
.map(item => {
return {
source: item.source,
description: item.text,
url: item.url,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if url should stick around and be removed in v8 (ditto for all these other audits), or are we good with removing the old properties immediately?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on whether we should keep the url field around until v8. However, if you decide to leave it for now please add a TODO to remove it later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like leaving it here too 👍

Copy link
Contributor

@Beytoven Beytoven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like a bad sign that there are no test changes in here when the audit details types are changing. Was there a major lack of coverage due to being old audits?

lighthouse-core/test/results/sample_v2.json Outdated Show resolved Hide resolved
lighthouse-core/gather/gatherers/console-messages.js Outdated Show resolved Hide resolved
"eventType": "protocolLog",
"source": "deprecation",
"level": "warning",
"text": "/deep/ combinator is no longer supported in CSS dynamic profile. It is now effectively no-op, acting as if it were a descendant combinator. /deep/ combinator will be removed, and will be invalid at M65. You should remove it. See https://www.chromestatus.com/features/4964279606312960 for more details.",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this deprecation noticed has been since deleted in Chromium.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -81,14 +81,15 @@ class ErrorLogs extends Audit {
/** @type {AuditOptions} */
const auditOptions = context.options;

/** @type {Array<{source: string, description: string|undefined, url: string|undefined}>} */
/** @type {Array<{source: string, description: string|undefined, sourceLocation: LH.Audit.Details.SourceLocationValue|undefined}>} */
const consoleRows = artifacts.ConsoleMessages
.filter(item => item.level === 'error')
.map(item => {
return {
source: item.source,
description: item.text,
url: item.url,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like leaving it here too 👍

"url": "http://localhost:10200/dobetterweb/dbw_tester.js",
"lineNumber": 13
"lineNumber": 13,
"columnNumber": 9
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@connorjclark connorjclark merged commit d46c769 into master Jan 14, 2021
@connorjclark connorjclark deleted the console-source-locations branch January 14, 2021 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"document.write()" line number is 0-indexed instead of 1-indexed
5 participants