This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
The callback provided to the executeAsyncScript function only accepts a single argument that is always treated as a successful completion. It should be possible for users to call this function with an error to indicate their script failed. Node.js has popularized the "Error-first" callback approach: errors are passed as the first argument, successful values the second. Another option would be to standardize on the Error-type. If the callback is invoked with an instanceof Error, the script is marked as a failure.
Here's another option: Change executeScript to recognize Promise[1] return values and eliminate executeAsyncScript as a command. If executeScript returns a promise, wait for it to settle. If the promise is resolved, use the resolved value as the command result. If the promise is rejected, return the reason with the command failure. If the promise doesn't resolve before the script timeout expires, fail the command. If there is a page unload event before the promise is resolved, fail the command (covering existing behavior of executeAsyncScript). [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise