Last Comment Bug 720760 - Object.defineProperty get function has incorrect `this`
: Object.defineProperty get function has incorrect `this`
Status: RESOLVED WORKSFORME
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: -- normal with 1 vote (vote)
: ---
Assigned To: Jeff Walden [:Waldo] (remove +bmo to email)
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-24 10:46 PST by Benjamin Smedberg AWAY UNTIL 2-AUG-2016 [:bsmedberg]
Modified: 2015-02-18 04:20 PST (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
PASS/FAIL TC (582 bytes, text/plain)
2012-01-24 11:04 PST, Michael A. Puls II
no flags Details
Pass/Fail TC (582 bytes, text/html)
2012-01-24 11:05 PST, Michael A. Puls II
no flags Details

Description Benjamin Smedberg AWAY UNTIL 2-AUG-2016 [:bsmedberg] 2012-01-24 10:46:18 PST
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 Michael A. Puls II 2012-01-24 11:04:26 PST
Created attachment 591181 [details]
PASS/FAIL TC
Comment 2 Michael A. Puls II 2012-01-24 11:05:59 PST
Created attachment 591182 [details]
Pass/Fail TC
Comment 3 Michael A. Puls II 2012-01-24 11:08:19 PST
System doesn't want to set text/html mime type for the attachment, even if I try explicitly.
Comment 4 Jeff Walden [:Waldo] (remove +bmo to email) 2012-01-24 12:01:53 PST
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.
Comment 5 Magnus Melin 2015-02-18 04:20:20 PST
It returns true now in firefox too.

Note You need to log in before you can comment on or make changes to this bug.