Skip to content

Call of toJSON in the internal JSON clone algorithm #1730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nechaev-chromium opened this issue Mar 24, 2023 · 0 comments
Open

Call of toJSON in the internal JSON clone algorithm #1730

nechaev-chromium opened this issue Mar 24, 2023 · 0 comments

Comments

@nechaev-chromium
Copy link

nechaev-chromium commented Mar 24, 2023

According to the internal JSON clone algorithm:

(if the serialized object) has an own property named "toJSON" that is a Function (...) return success with the value returned by Function.[[Call]](toJSON) with value as the this value.

The standard does not mention what to do with inherited property toJSON of the serialized object. Would it make sense to handle toJSON uniformly for both own and inherited toJSON property?

Use case:
According to the ECMAScript standard toJSON is an inherited property of Date object defined in Date.prototype. As it is not an own property we have to serialize Date as an object instead of calling Date.prototype.toJSON

Implementations:
ChromeDriver

  • The serialization of Date object used to call Date.prototype.toJSON until ver 111
  • Starting from ver 111 ChromeDriver serializes Date as Object yielding {}. The result seems to be unexpected for the users chromedriver:4395.

GeckoDriver
It looks like it also calls Date.prototype.toJSON as the serialization result is a string of the form YYYY-MM-DDTHH:mm:ss.sssZ (ISO8601)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant