Object.defineProperty get function has incorrect `this`

RESOLVED WORKSFORME

Status

()

Core
JavaScript Engine
RESOLVED WORKSFORME
5 years ago
2 years ago

People

(Reporter: bsmedberg, Assigned: Waldo)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

582 bytes, text/html
Details
(Reporter)

Description

5 years ago
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.

Comment 1

5 years ago
Created attachment 591181 [details]
PASS/FAIL TC

Comment 2

5 years ago
Created attachment 591182 [details]
Pass/Fail TC
Attachment #591181 - Attachment is obsolete: true

Comment 3

5 years ago
System doesn't want to set text/html mime type for the attachment, even if I try explicitly.

Updated

5 years ago
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

Comment 5

2 years ago
It returns true now in firefox too.
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.