sitespeedio / chrome-har

Create HAR files from Chrome Debugging Protocol data
MIT License
149 stars 50 forks source link

Redirects in main document are not detected as new page (explicit redirect or navigation) #65

Open xavier-medioni opened 4 years ago

xavier-medioni commented 4 years ago

Hi everybody !

At first, thanks for this very useful tool !

And I wanted to suggest an improvement about a multi page HAR output, and I will try to provide as many elements as possible.

Usecase:

page1.html: loading 3 images + 1 js file, redirecting to page2.html on DOMContentloaded + 500ms page2.html: loading 2 images

With chrome-har:

1-page-detected

1-page-detected-pages-section

With Chrome Devtools > Save all as HAR with content:

2-pages-detected

2-pages-detected-pages-section

Suspicion:

strong-suspicion

protocol-monitor

Alternative / extended behaviour:

Thanks by advance !

soulgalore commented 4 years ago

Hi @xavier-medioni thanks for creating the issue! So for redirects its been that by choice, with the idea that you choose to test one page, it redirects to the "same" page that you wanted to test.

For multi, yeah, I started to do that before but it started to get too complicated at that time. That's low prio for me but if someone is interested maybe I can guide you through it.

xavier-medioni commented 4 years ago

Hi @soulgalore,

Thank you for your reply. As you probably already guessed, I was trying to evaluate, from a network point of view, the cost of a potential redirect, capturing protocol events "live", and using harFromMessages. I tried to tweak the existing harFromMessages method to add page on "Page.frameScheduledNavigation" event (maybe the most convenient event to track to detect redirects), but got stucked due to an exception because const entrySecs = page.wallTime + (timing.requestTime - page.timestamp); with page.wallTime and page.timestamp were null. I noticed the use of addFromFirstRequest, (addFromFirstRequest(page, paramsWithoutPage[0]), also called into "Network.requestWillBeSent" case), but not yet sure about how to use it for this usecase.

If you have any lead, I could be working on it.