简体   繁体   中英

Serializing the complete Javascript state of a website including Closure/Hidden scopies?

I would like to save a "snapshot" of a webpage which however should remain in an "interactive" state -> all Javascript state has to be saved and restored.

Example showing the issue I'm trying to solve: Given a webpage which executes the following script in the global scope:

function f(x) { return function() { return x; } }
var g = f(2);

I'd like to save both the function f (more or less trivial) and the variable g (which closes over x from the f invocation) to a file and restore the state of the website later.

As far as I could figure out it seems to be impossible to do this using only "web" technologies (ie. with the permissions the webpage itself has). I'm therefore guessing I'll have to implement a browser addon to achieve this.

Does something like this already exist? What would be a good starting point? I noticed that Firefox Session Restore does something similar, do you know if I could reuse this mechanism? If not would it be feasible to implement something like this as a "debugger" style addon? Are there simpler solutions?

Javascript objects hold onto DOM/other native objects. Native objects have hidden state and can be entangled with global browser state or addons.

So the only real way I can think of is to run a browser in a VM and snapshot/clone that VM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM