Skip to content

Call of toJSON in the internal JSON clone algorithm #1730

Open
@nechaev-chromium

Description

@nechaev-chromium

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions