Possibility to restore javascript context / page state

29 views
Skip to first unread message

depre...@gmail.com

unread,
Mar 13, 2018, 2:22:22 PM3/13/18
to Chrome DevTools
Hi,

I need to quickly restore the "initial" state of a loaded page (read: the page html / css / js state after everything was loaded the first time, ignoring continuous polling, changing elements, etc...). My use case is the following:

1. Load a page
2. Wait for it to be ready (up to some given criteria)
3. Store the state here as initial state
4. Do some interactions with the page that'll change the state (like clicking a button)
5. Reload the state stored in 3.
6. Do 3-4-5 again and again.

Because it's done many many times I need to be as fast as possible. What I've tried:
- aggressive proxy to cache the first requests so I can just reload the page in the usual sense -> there are some overhead and since the parsing may not be deterministic, it can lead to buggy states.
- cache the first initial html, reset the document to it and let the rest of the parsing / requests happen -> that works in theory, but it can still lead to a lot of requests (think of SPAs), so too slow.
- try to set breakpoints on the javascript, but I failed to see how it could lead to go back to the initial JS.

I realized it's a hard problem and I'm quite stuck here. So my question is:
- do you have any ideas on how to solve it? 
- is there somehow a possibility to "bulk-store" a JS context and restore it? Is it even possible at the C++ level API?

Maybe it's not the best group, so feel free to redirect me to another one.

Thanks a lot!
Reply all
Reply to author
Forward
0 new messages