Helpers to wait for, and stub javascript