w3c / w3c/webdriver

Is returned Symbol value expected to be serialized as an empty object for executing script?

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

Nobody has claimed this yet.

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

Description

while trying to return a Symbol (like following script) from execute sync command, I realized the Symbol will be serialized into an empty object.

return Symbol(1);

Based on the internal JSON clone algorithm, if the value is a Symbol, it will run to the last Otherwise branch. Thus, IIUC, it will get into clone an object and end up returning an empty object.

However, JSON.stringify(Symbol(1)) returns undefined. It's not serialized into an empty object. So, I wonder if we should serialize Symbol values to null (like what undefined is serialized) as well?

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 WebDriver internal JSON clone algorithm and its clone-an-object branch, then compare that behavior with JSON.stringify(Symbol(1)) and the execute sync command described here. Determine the intended serialization for Symbol values and update the relevant WebDriver specification text; done means the algorithm and expected result are unambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.