8000
Skip to content

new_audit: add valid-source-maps audit - #11236

Merged
devtools-bot merged 50 commits into
masterfrom
valid-source-maps
Aug 19, 2020
Merged

new_audit: add valid-source-maps audit#11236
devtools-bot merged 50 commits into
masterfrom
valid-source-maps

Conversation

@saavan-google
@saavan-google saavan-google commented Aug 7, 2020
Copy link
Copy Markdown
Contributor

(cont. from #10313)

Summary
This PR adds a new audit which fails if a user has large, first-party JavaScript with invalid or missing source maps. The audit shows a table with two columns (the JavaScript URLs and the source map URLs). Additionally, the audit performs a trivial detection of source map validity, and displays the corresponding error messages if there are any. A deeper validation of the source map is something to consider for a separate PR.

TBD: Add tests

Screenshot 1 | Audit Failure State
Valid Source Maps - With Error

Screenshot 2 | Audit Success State
Valid Source Maps - Without Error

Screenshot 3 | Sorting Bug
Sorting Bug

Related Issues/PRs

@saavan-google
saavan-google requested a review from a team as a code owner August 7, 2020 07:35
@saavan-google
saavan-google requested review from connorjclark and removed request for a team August 7, 2020 07:35
@googlebot
Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@brendankenny brendankenny left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work! Some quick structural feedback that's hopefully helpful.

Comment thread types/source-maps.ts Outdated
Comment thread lighthouse-core/config/experimental-config.js Outdated
Comment thread lighthouse-core/config/experimental-config.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/test/fixtures/source-maps/angular.min.js Outdated
@connorjclark connorjclark left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

left comments + need some unit tests

Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
let missingMapsForLargeFirstPartyFile = false;
const results = [];
for (const ScriptElement of artifacts.ScriptElements) {
if (!ScriptElement.src) continue; // TODO: inline scripts, how do they work?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was a note I took because I need to go through all uses of our source maps and see what happens if the script is inline with a source map url comment. I think many usages assume a network record exists, and I'm not sure what happens when that network record is the HTML document. I don't think inline bundled code is common ... so the work involved may just be to ensure it doesn't blow up Lighthouse. if supporting it would be too much work we won't bother.

I need to file an issue, then we can link to it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was a note I took because I need to go through all uses of our source maps and see what happens if the script is inline with a source map url comment.

What does it mean for the script to be inline with a source map url comment?

I don't think inline bundled code is common ... so the work involved may just be to ensure it doesn't blow up Lighthouse.

In this case, would an error be caught within the audit or break the entire runner?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What does it mean for the script to be inline with a source map url comment?

<script>
a;b;f;d;a;a;s;s;minified code.....

// sourceMapURL=file.js.map
</script>

In this case, would an error be caught within the audit or break the entire runner?

I'm not sure, that's the investigation that this comment is alluding needs to be done. first of all, here L82 const sourceMap = wouldn't work because there is not a url to tie together a source map and an inline script. I think the source map gatherer may not even process inline scripts?

in any case, it's not a high priority concern to support. I'd just want to see what happens w/ an inline script w/ a map, dbl check none of these new audits error.

Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/config/experimental-config.js Outdated
Comment thread lighthouse-core/config/experimental-config.js Outdated
Comment thread lighthouse-core/config/experimental-config.js Outdated
@saavan-google
Copy link
Copy Markdown
Contributor Author

PTAL - I updated the PR description with screenshots

Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
@googlebot
Copy link
Copy Markdown

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

Comment thread lighthouse-core/test/audits/valid-source-maps-test.js
Comment thread lighthouse-core/test/audits/valid-source-maps-test.js
@connorjclark
Copy link
Copy Markdown
Collaborator

should this be named just source-maps? #11266 @patrickhulce

@saavan-google
Copy link
Copy Markdown
Contributor Author

should this be named just source-maps? #11266 @patrickhulce

What about has-source-maps?

@patrickhulce
patrickhulce commented Aug 19, 2020
Copy link
Copy Markdown
Collaborator

What about has-source-maps?

We actually just decided in our discussion about #11266 that verbs and phrases are 👎 and nouns with adjectives are 👍 moving forward @SaavanNanavati :)

should this be named just source-maps? #11266 @patrickhulce

I actually like valid-source-maps per "Adjective modifiers are acceptable, and encouraged if it would be too broad". We might have multiple things in source map initiatives in the future it seems?

Is your counterpoint to the valid- prefix @connorjclark that this audit also encourages you to have them at all in addition to validating?

@connorjclark
Copy link
Copy Markdown
Collaborator

Is your counterpoint to the valid- prefix @connorjclark that this audit also encourages you to have them at all in addition to validating?

yes

@patrickhulce
Copy link
Copy Markdown
Collaborator

The verbosity of your argument has convinced me! 😆

Can I sell you on any adjectives that attempt to combine those two ideas: invalid and/or missing

  • incomplete-source-maps
  • inadequate-source-maps
  • deficient-source-maps

The challenge with our policy in #11266 is that this audit surfaces scripts OR source maps depending on the situation so "noun of the thing being surfaced" doesn't work so well :/

Comment thread lighthouse-core/test/audits/valid-source-maps-test.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Comment thread lighthouse-core/audits/valid-source-maps.js Outdated
Co-authored-by: Connor Clark <cjamcl@google.com>
@Saavan-Nanavati
Copy link
Copy Markdown

@googlebot I consent.

@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

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.

8 participants

0