The script never touches the page. It runs in a throwaway worker whose only power is to ask the main thread for an action. The main thread checks each request and performs it.
←/→ step · Space play/pause · R replay · Home/End jumpStep 5 of 5
Every await ui.something() in the script is one request across this boundary. The worker is created for one script and terminated when it finishes, times out, or misbehaves.