简体   繁体   English

序列化网站的完整Javascript状态,包括关闭/隐藏调查表?

[英]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. 我想保存网页的“快照”,但是应该保持“交互”状态->必须保存和还原所有Javascript状态。

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. 我想将函数f(或多或少是微不足道的)和变量g(从f调用关闭x)都保存到文件中,并稍后恢复网站的状态。

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). 据我所知,似乎仅使用“ Web”技术(即具有网页本身的权限)是不可能的。 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? 我注意到Firefox Session Restore做类似的事情,您知道我是否可以重用此机制? 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. Javascript对象保留在DOM /其他本机对象上。 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. 因此,我能想到的唯一真实的方法是在VM中运行浏览器并快照/克隆该VM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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