State machines for the web