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(scriptelements): expose id attribute for ScriptElements #9718

Merged
merged 5 commits into from Sep 27, 2019

Conversation

uchoudh-zz
Copy link
Contributor

@uchoudh-zz uchoudh-zz commented Sep 23, 2019

Summary

This is a small feature to include the id attribute in the output when ScriptElements are requested in an audit.

This change makes it easier to choose a specific script and adds ease of use when writing audits.

Related Issues/PRs
This is the issue that the PR addresses. #9681

@uchoudh-zz uchoudh-zz changed the title core(ScriptElements): expose id attribute in for Script core(scriptelements): expose id attribute in for Script Sep 23, 2019
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.

thanks for taking this on @uchoudh!

There are a few more places that will need updating:

  • the artifacts type for ScriptElements. Probably helpful to leave a comment that the value will be null if the element had no id or if source is network.
  • an explicit null id value down in the version returned in L81-90 (no id for those because they are js file network requests)
  • run yarn update:sample-artifacts ScriptElements to update a set of saved test artifacts to include id where applicable
  • run yarn update:sample-json to update any cases where the updated artifacts may affect things (I don't imagine this will end up doing anything because we don't yet use id anywhere :)

thanks, and don't hesitate to leave a comment if you run into unexpected trouble!

@uchoudh-zz
Copy link
Contributor Author

First three changes are looking good. Having some trouble with yarn update:sample-json.
Getting this error regarding google protobuff
Install protobuf ≥ 3.7.1 to compile the proto file

Steps I took:

  1. npm install google-protobuf
  2. Download the protobuf compiler from https://github.com/protocolbuffers/protobuf/releases/tag/v3.10.0-rc1

After these steps not sure how to use it with the lighthouse project.

@patrickhulce
Copy link
Collaborator

@uchoudh are you using a Mac and homebrew?

I just needed to brew install protobuf (or brew upgrade protobuf if you have an older version) without manually downloading the compiler from github.

@uchoudh-zz uchoudh-zz changed the title core(scriptelements): expose id attribute in for Script core(scriptelements): expose id attribute for ScriptElements Sep 24, 2019
@uchoudh-zz
Copy link
Contributor Author

uchoudh-zz commented Sep 24, 2019

@patrickhulce Yes I am using a mac and homebrew. I tried the what you suggested but the problem still persists. I think it's still an error with protobuf not bring installed properly but the error message is a little different.
ImportError: No module named google.protobuf.internal
Looked around for similar issues but none of those solutions seem to fix it for me.

@brendankenny
Copy link
Member

@uchoudh I think some people have run into this before. Check out this comment: #9084 (comment)

You can also commit what you have and one of us can run the command.

Sorry for the trouble!

@uchoudh-zz
Copy link
Contributor Author

@uchoudh I think some people have run into this before. Check out this comment: #9084 (comment)

You can also commit what you have and one of us can run the command.

Sorry for the trouble!

Thank you. I've pushed my latest changes.

@brendankenny
Copy link
Member

Looks like we haven't run yarn update:sample-artifacts ScriptElements in a while so it was pulling in a lot more changes than I thought it would (e.g. #9672 makes unminified-javascript pass in sample_v2.json).

I reverted most of it and kept just the id entries so that someone else can deal with it someday :) I also sprinkled in a few IDs to make sure they were making their way to the artifacts, even though no one is using them yet.

  • run yarn update:sample-json to update any cases where the updated artifacts may affect things (I don't imagine this will end up doing anything because we don't yet use id anywhere :)

with these more minimal changes to the saved artifacts, yarn update:sample-json makes no updates

@uchoudh-zz
Copy link
Contributor Author

@googlebot I consent.

types/artifacts.d.ts Outdated Show resolved Hide resolved
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
@GoogleChrome GoogleChrome deleted a comment from googlebot Sep 25, 2019
@GoogleChrome GoogleChrome deleted a comment from googlebot Sep 25, 2019
@GoogleChrome GoogleChrome deleted a comment from googlebot Sep 25, 2019
@brendankenny
Copy link
Member

oh googlebot...

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, thanks @uchoudh!

@@ -109,7 +109,7 @@ module.exports = [
},
{
source: 'Runtime.exception',
description: 'Error: An error\n at http://localhost:10200/dobetterweb/dbw_tester.html:57:38',
description: /^Error: A distinctive error\s+at http:\/\/localhost:10200\/dobetterweb\/dbw_tester.html:\d+:\d+$/,
Copy link
Member

Choose a reason for hiding this comment

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

another annoying failure for new contributors :) Made the smoke test expectation less sensitive because we don't need to verify the exact column number

@googlebot
Copy link

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.

@GoogleChrome GoogleChrome deleted a comment from googlebot Sep 27, 2019
@GoogleChrome GoogleChrome deleted a comment from googlebot Sep 27, 2019
@brendankenny brendankenny merged commit 6dde98c into GoogleChrome:master Sep 27, 2019
@brendankenny
Copy link
Member

Thanks @uchoudh!

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.

None yet

5 participants