-
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: always use MainResource
for main document
#13756
Conversation
@@ -394,6 +394,8 @@ class PageDependencyGraph { | |||
const networkNodeOutput = PageDependencyGraph.getNetworkNodeOutput(networkRecords); | |||
const cpuNodes = PageDependencyGraph.getCPUNodes(processedTrace); | |||
|
|||
// TODO: Remove this usage of `findMainDocument`. This assumption isn't true if there was a JS redirect. | |||
// ... |
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.
This file seems to depend mainDocumentRequest
actually being the "first document request" in the case of a JS redirect. It might require a larger refactor in a different PR to eliminate the usage of NetworkAnalyzer.findMainDocument
here.
@@ -7,11 +7,10 @@ | |||
|
|||
/** | |||
* @param {LH.Artifacts.NetworkRequest[]} networkRecords | |||
* @param {LH.Artifacts.Script|undefined} 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.
Drive-by
This PR aims to use the
MainResource
computed artifact universally instead of callingNetworkAnalyzer.findMainDocument
directly. There are two reasons we would want to do this:NetworkAnalyzer.findMainDocument
. If we useMainResource
universally, we will only need to assert the main document URL exists withinMainResource
.NetworkAnalyzer.findMainDocument
will return the first document request if it is not given a URL as its second parameter. This will return an incorrect network request if there was a JS redirect. There are a few places where this can be confusing/problematic. See Improve handling of redirects, navStart #8984.