w3c / webdriver

Remote control interface that enables introspection and control of user agents.
https://w3c.github.io/webdriver/
Other
676 stars 190 forks source link

Improve handling of objects and collections in "internal JSON clone algorithm" #1709

Closed whimboo closed 1 year ago

whimboo commented 1 year ago

Currently in step 2 of clone an object only the own enumerable properties are taken into account. This actually causes issues with WebIDL interfaces like File which won't get the name property serialized.

Interestingly we have a specific wdspec test for a FileList case, which requires the name property serialized. And all browsers are currently passing this test.

As such we probably want to remove the restriction for only serializing own properties, and allow to serialize all the enumerable properties. This won't cause a regression and keeps the behavior that is currently shown by browsers.

CC @jgraham, @sadym-chromium, @patrickangle, @gsnedders, @shs96c.


Preview | Diff

whimboo commented 1 year ago

Here an example snippet to replicate the behavior - no properties are returned in each of the browsers:

var file = new File(["foo"], "bar");
Object.getOwnPropertyNames(file);
whimboo commented 1 year ago

This PR actually needs some more updates given that there are other failing cases:

whimboo commented 1 year ago

@jgraham your feedback would be welcome! I've updated all the different parts of the spec that we agreed on need changes. New tests for the changes will be supplied via https://bugzilla.mozilla.org/show_bug.cgi?id=1794078.