-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
StructuredClone of prototype objects #9730
Comments
This is a bug against Gecko/WebKit :) |
@ADKaster If you open FF/WebKit issues for this, you may wish to note that (at least in FF) this doesn’t appear to be unique to %RegExp.prototype%. Firefox is rejecting every intrinsic prototype despite the absence of own enumerable properties that would cause failure for other reasons — %Date.prototype%, %Error.prototype%, %WeakMap.prototype%, etc. Since this amounts to a hidden branding mechanism for non-callable intrinsic objects that should be possible to reimplement/virtualize in the ES layer, pinging @mhofman & @erights. |
@bathos ah, I created bugs for both of those earlier today https://bugzilla.mozilla.org/show_bug.cgi?id=1853050 |
Thanks! Pinging also @ljharb , who is interested in such branding abilities. |
@erights I left additional FF-specific findings on @ADKaster’s Bugzilla issue, including that some exceptions exist and that (most) intrinsic namespace objects (%Math%, etc) are affected, too. The specific hidden cross-realm brand object set is likely different in WebKit, but I’m not able to test there presently. |
The spec steps for structured serialize internal https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal don't seem to preclude serializing object prototypes:
In step 21, the algorithm precludes any objects with funky internal slots
If we look at the ES spec for RegExp Prototype: https://tc39.es/ecma262/#sec-properties-of-the-regexp-prototype-object
It says that that object:
Which suggests to me that it should fall through to the next step, step 23, which says:
Since %RegExp.prototype% is an ordinary object, it's not exotic, and so it should be cloneable as any other object.
However, only chromium lets me structuredClone this object, both Firefox and Safari reject it.
Is the intention of the spec to disallow cloning intrinsic prototype objects, or is this a bug against Gecko/Webkit?
The text was updated successfully, but these errors were encountered: