Closed Bug 720760 Opened 8 years ago Closed 5 years ago

Object.defineProperty get function has incorrect `this`

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: benjamin, Assigned: Waldo)

Details

Attachments

(1 file, 1 obsolete file)

I'm filing this bug report from a newsgroup post in mozilla.dev.apps.firefox:

Object.defineProperty(String.prototype, "com_example_bool", {
     get : function() {
         return (/^(true|1)$/i).test(this);
     }
});

alert("true".com_example_bool);

That returns true in Opera, IE9, Chrome Canary and Safari, but returns  
false in Firefox (at least latest trunk).

Anyone know why?

A quick investigation shows that in the get() function, uneval(this) gives me:

(new String("")) instead of the "true" string I would expect. I don't think this has anything to do with the regex part of the testcase.
Attached file PASS/FAIL TC (obsolete) —
Attached file Pass/Fail TC
Attachment #591181 - Attachment is obsolete: true
System doesn't want to set text/html mime type for the attachment, even if I try explicitly.
Attachment #591182 - Attachment mime type: text/plain → text/html
Yeah, getters and setters on the boxed-type prototypes get a boxed |this| when invoked through property accesses on primitive values.  Known, certainly needs fixing.  I'll take this and see what I can do for it.
Assignee: general → jwalden+bmo
Status: NEW → ASSIGNED
OS: Mac OS X → All
Hardware: x86 → All
It returns true now in firefox too.
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.