w3c / w3c/webdriver

Define error semantics on serialising JS return values

Open
#1,349 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Execute Async Script Execute Script
Dominant language
HTML
Stars
718
Forks
228
PR merge metrics
No merged PRs in 30d

Description

As @domenic pointed out to me in #whatwg, we have failed to define error behaviour related to the Execute Script and Execute Async Script commands. For any JS object an injected script interacts with, there is a chance of failure.

This is especially problematic for the internal JSON clone algorithm that serialises return values from injected scripts. If we for example consider the following injected script:

let rv = new Array(3);
Object.defineProperty(Array.prototype, "1", { get () { throw new Error("foo"); } })
return rv;

Here there is no chance of avoiding hitting the error when the array’s items are serialised in turn. The failure case above needs to be defined in detail.

(Depending on the implementation of the driver, script injection overriding document prototypes may also effect other commands that in theory are meant to work on the underlying data structures indepedently of prototype overrides, but I think this is outside the scope of this issue.)

This issue is related to the one @jugglinmike filed about fixing collection serialisation following my change.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the internal JSON clone algorithm and the Execute Script and Execute Async Script command definitions in the WebDriver specification. Compare the serialization failure example with related issue #1347 and pull request #1340; done means the specification defines the error behavior for failures while serialising injected-script return values.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.