w3c / webdriver

Remote control interface that enables introspection and control of user agents.
https://w3c.github.io/webdriver/
Other
679 stars 194 forks source link

`internal JSON clone algorithm` has to raise "javascript error" if object's `toJSON()` method throws #1711

Open whimboo opened 1 year ago

whimboo commented 1 year ago

https://github.com/w3c/webdriver/issues/849 implemented the feature to call toJSON() for internal JSON clone algorithm if it exists on an object. But as seen while working on https://github.com/w3c/webdriver/pull/1709 it misses to catch errors potentially thrown by executing this method.

In such a situation the error as raised should be caught and re-thrown as javascript error.

jgraham commented 1 year ago

The fundamental issue is that in order to actually do that we need to set up an execution environment and handle the fact that the return type is an ES completion record (i.e. the equivalent of a Result<T, E>). There's a few places where we just casually try to perform operations that could execute script without being specific about where we do it, or how errors are handled.