webdriver icon indicating copy to clipboard operation
webdriver copied to clipboard

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

Open CYBAI opened this issue 3 years ago • 0 comments

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?

CYBAI avatar Jul 14 '22 04:07 CYBAI