Exact Replay

How can you return to the exact same state of a running webpage?

How do you “replay” the execution of a page—if the random number generator returns a particular random number, reproducibly return the same random number—if a particular image is loaded, load the same image—if JavaScript queries the current time, return the same time—in short, reproduce the execution of a particular page?

I also considered saving the state of the running binary as a blob, but this seems more memory-intensive.

I’m willing to do a LOT of work. I really want to be able to “go back” to the same state when developing firefox and see the exact same error.