ES6 "name" property of functions should be configurable

RESOLVED FIXED in mozilla38

Status

()

defect
RESOLVED FIXED
5 years ago
4 years ago

People

(Reporter: bzbarsky, Assigned: till)

Tracking

(Blocks 1 bug, {dev-doc-complete})

Trunk
mozilla38
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [DocArea=JS])

Attachments

(1 attachment)

+++ This bug was initially created as a clone of Bug #911142 +++

Just like bug 911142 but for "name".  Simple tests:

  Object.getOwnPropertyDescriptor(Object, "name").configurable
  Object.getOwnPropertyDescriptor(function foo(){}, "name").configurable
(Assignee)

Comment 1

4 years ago
We had one really short test covering the previous behavior, it seems.

I removed that and added tests covering everything I could think of.

Slightly bungled (wrong commit message, forgot the reportCompare song-and-dance) try-run without web platform tests here:
https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=b6348b75b5b7

New try run with issues fixed, but containing just the web platform tests:
https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=3310bb12900e

This builds on top of the similar patch for "length", so should land after or with that.
Attachment #8536237 - Flags: review?(jorendorff)
(Assignee)

Updated

4 years ago
Assignee: nobody → till
Status: NEW → ASSIGNED
Comment on attachment 8536237 [details] [diff] [review]
Make the "name" property of function objects configurable

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

Cool. Thanks.

::: js/src/jsfun.cpp
@@ +489,5 @@
>      if (isLength || JSID_IS_ATOM(id, cx->names().name)) {
>          MOZ_ASSERT(!IsInternalFunctionObject(obj));
>  
>          RootedValue v(cx);
> +        // Since f.length and f.name are configurable, they could be resolved

Blank line before this comment, please, as required by the style guide (except when the preceding line ends with '{').

::: js/src/tests/ecma_6/Function/function-name.js
@@ +6,5 @@
> +    assertEq(f.name, '');
> +    assertEq(f.hasOwnProperty('name'), false);
> +    f.name = 'g';
> +    assertEq(f.name, '');
> +    Object.defineProperty(f, 'name', {value: 'g'});

Could add one more assertion after this, since it should succeed in defining a new 'name' property.
    assertEq(f.name, 'g');
or something.
Attachment #8536237 - Flags: review?(jorendorff) → review+
https://hg.mozilla.org/mozilla-central/rev/be17c68f88cb
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.