Closed Bug 1008441 Opened 10 years ago Closed 10 years ago

Object.defineProperty(proxy, desc) parses desc twice

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: jorendorff, Assigned: jorendorff)

References

Details

Attachments

(1 file, 2 obsolete files)

The first time when js::DefineOwnProperty calls PropDesc::initialize.

The second time when js::DefineProperty calls Proxy::defineProperty(JSContext *cx, HandleObject proxy, HandleId id, HandleValue v)

This is observable using standard ES6 library features, since the descriptor may also be a proxy.

(More to the point, this means you can't call js::DefineProperty passing a PropDesc that doesn't have an initialized pd_ field for Proxy::defineProperty to redundantly parse. Since I want to do that for Array.from, I have to fix this bug.)
That Proxy::defineProperty signature turns out to be used only in these two places, so delete it.
Assignee: nobody → jorendorff
Attachment #8420400 - Flags: review?(jwalden+bmo)
Comment on attachment 8420400 [details] [diff] [review]
bug-1008441-PropDesc-twice-v1.patch

Review of attachment 8420400 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/jsobj.cpp
@@ +223,5 @@
> +    if (!hasConfigurable() || !configurable())
> +        attrs |= JSPROP_PERMANENT;
> +    if (hasEnumerable() && enumerable())
> +        attrs |= JSPROP_ENUMERATE;
> +    if (!hasWritable() || !hasWritable())

Change to `!hasWritable() || !writable()` ?
Uh. Wow. How did I manage to write that? Good catch.
Actually, even with hasWritable(), that line was busted. We must not set JSPROP_READONLY if the descriptor is an accessor descriptor.
Attachment #8420400 - Attachment is obsolete: true
Attachment #8420400 - Flags: review?(jwalden+bmo)
Attachment #8425777 - Flags: review?(jwalden+bmo)
Blocks: 904723
Blocks: 1015790
Rebased on top of Eric's patches in bug 978238, which contain the populatePropertyDescriptor method I'm using... bumping review to Eric too.
Attachment #8430383 - Flags: review?(efaustbmo)
Attachment #8425777 - Attachment is obsolete: true
Attachment #8425777 - Flags: review?(jwalden+bmo)
Comment on attachment 8430383 [details] [diff] [review]
bug-1008441-PropDesc-twice-v3.patch

Review of attachment 8430383 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good. Thanks for doing this. r=me
Attachment #8430383 - Flags: review?(efaustbmo) → review+
Depends on: 978238
https://hg.mozilla.org/mozilla-central/rev/3825abd9a302
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: