facebook / memlab

A framework for finding JavaScript memory leaks and analyzing heap snapshots
https://facebook.github.io/memlab/
MIT License
4.35k stars 118 forks source link

Is it possible to set browser headers for each scenario? #42

Closed willemliufdmg closed 1 year ago

willemliufdmg commented 1 year ago

I was searching through the docs but couldn't find a way to set request headers for each scenario to use.

Is there a way to set request headers?

JacksonGL commented 1 year ago

@willemliufdmg Does calling page.setExtraHTTPHeaders inside the setup callback work for your use case?

willemliufdmg commented 1 year ago

@willemliufdmg Does calling page.setExtraHTTPHeaders inside the setup callback work for your use case?

Thank you for the suggestion. I'll give it a try today and get back to you.

willemliufdmg commented 1 year ago

@willemliufdmg Does calling page.setExtraHTTPHeaders inside the setup callback work for your use case?

At first I thought it was working. But I was looking at the wrong thing. Sadly your suggestion doesn't work as the headers are set after initial page load with this method.

I wanted to set headers so it's being sent with every request.

JacksonGL commented 1 year ago

We may be able to add a new callback before the initial page load (something like beforeInitialLoad(page))

willemliufdmg commented 1 year ago

We may be able to add a new callback before the initial page load (something like beforeInitialLoad(page))

That would be great. Then it would be possible to add headers or whatever else is necessary before a page request has been sent.

JacksonGL commented 1 year ago

New API: https://facebook.github.io/memlab/docs/api/interfaces/core_src.IScenario/#-optional-beforeinitialpageload-interactionscallback