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(third-party-summary): check main domain against all third party domains #10006

Merged

Conversation

mikedijkstra
Copy link
Contributor

Summary
This PR fixes a bug where if you run an audit on a domain that's in third-party-web it records all scripts from that domain as a third party.

For example running an audit against the url my-pr-3.netlify.com will record all scripts retrieved from my-pr-3.netlify.com against the third party Netlify, even though they're first party scripts.

The change intended to fix this issue is to compare the domain of the main resource url against all request urls and skip the ones that match.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@mikedijkstra
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

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.

thanks very much @micdijkstra! excited to get this in :)

lighthouse-core/audits/third-party-summary.js Outdated Show resolved Hide resolved
lighthouse-core/audits/third-party-summary.js Outdated Show resolved Hide resolved
lighthouse-core/test/audits/third-party-summary-test.js Outdated Show resolved Hide resolved
- Use computed `MainResource`
- Filter third party entries if main domain matches any third party
  domain
- Update tests to use `networkRecordsToDevtoolsLog`
@mikedijkstra mikedijkstra changed the title core(third-party-summary): Do not record third party that matches main resource domain core(third-party-summary): check main domain against all third party domains Nov 25, 2019
@mikedijkstra
Copy link
Contributor Author

@patrickhulce This has been updated to reflect your requested changes.

I didn't want to add the mainResource to getSummaryByEntity so now we're filtering the entries before they're mapped into results. The domain comparison is a little tricky as we're now comparing wildcard domains with urls. I'm not across what's available so please let me know if there's a better way!

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 % test change

lighthouse-core/test/audits/third-party-summary-test.js Outdated Show resolved Hide resolved
lighthouse-core/audits/third-party-summary.js Show resolved Hide resolved
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.

hang on you'll need to add URL to the requiredArtifacts to fix the test issue too :)

@mikedijkstra
Copy link
Contributor Author

@patrickhulce I've updated the test and included the comment.

hang on you'll need to add URL to the requiredArtifacts to fix the test issue too :)

I was going to ask about that test, thanks for the tip! Looks like it's green ✅

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, thanks so much @micdijkstra!

@patrickhulce patrickhulce merged commit 105f30d into GoogleChrome:master Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants