-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: resolve redirected script records #13751
Conversation
@@ -372,11 +372,8 @@ class LegacyJavascript extends ByteEfficiencyAudit { | |||
let transferRatio = transferRatioByUrl.get(url); | |||
if (transferRatio !== undefined) return transferRatio; | |||
|
|||
const mainDocumentRecord = NetworkAnalyzer.findOptionalMainDocument(networkRecords); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using findOptionalMainDocument
without specifying a URL will just find the first document request. This isn't necessarily the main document if there was a redirect though.
I think it makes more sense to just get the main document record using the script URL like any other script in this case. For timespan/snapshot, finalUrl
isn't necessarily the main document URL either #13706.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup! and this would very much be a bug for inline scripts in iframes. not sure why we (Read: I) did it this way 🤔
const networkRecord = url === artifacts.URL.finalUrl ? | ||
mainDocumentRecord : | ||
networkRecords.find(n => n.url === url); | ||
const networkRecord = getRequestForScript(networkRecords, script); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could const url
be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still used in multiple places, I think we can leave it.
@@ -372,11 +372,8 @@ class LegacyJavascript extends ByteEfficiencyAudit { | |||
let transferRatio = transferRatioByUrl.get(url); | |||
if (transferRatio !== undefined) return transferRatio; | |||
|
|||
const mainDocumentRecord = NetworkAnalyzer.findOptionalMainDocument(networkRecords); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup! and this would very much be a bug for inline scripts in iframes. not sure why we (Read: I) did it this way 🤔
96f0c8d
to
94e93cc
Compare
9.6.0 note: Added `fakeScript` var to places to make up for the fact that this release does not have "Scripts" refactor.
Fixes #13724