Closed bzbarsky closed 5 years ago
What's the difference between the option 2 and 3? How do you specify the target global in the algorithm?
What's the difference between the option 2 and 3?
Hmm. I guess what we are doing with the resulting object is structured cloning it, not converting it back to a dictionary, so maybe there is no difference in practice, because structured cloning is never affected by the prototype, right? (This claim needs to be carefully double-checked!)
If that's correct, then we can just use https://heycam.github.io/webidl/#dictionary-to-es as-is; it picks up the global from the ambient "current Realm" state, which should be fine here.
not converting it back to a dictionary
Yes. It's just an intermediate step for the post-messaging.
Note that someone still needs to:
1) Carefully double-check that structured cloning ignores prototypes.
2) Add a test where there are relevant properties on Object.prototype
, an Object.create(null)
is passed as the dictionary, and the test checks that those properties don't pop out on the far end.
Thanks for the verification @padenot! Per last 2 comments above, I think we can merge #1996.
https://webaudio.github.io/web-audio-api/#instantiation-of-AudioWorkletNode-and-AudioWorkletProcessor step 7 says:
But at this point options is an IDL dictionary (in particular an
AudioWorkletNodeOptions
), whileStructuredSerialize
takes as input an IDL value, not an ES value. It's not 100% clear where this ES value should come from. Possible options are:1) The original ES object the
AudioWorkletNodeOptions
was created from. This is not generally available from a dictionary, though. 2) A new ES object derived by calling https://heycam.github.io/webidl/#dictionary-to-es in the current global. 3) A new ES object derived by calling https://heycam.github.io/webidl/#dictionary-to-es in a clean new global.These are all observably different from each other when proxies and getters on Object.prototype are involved.
The spec should really define what happens here, and there should be tests for the behavior.
@karlt