Last Comment Bug 720760 - Object.defineProperty get function has incorrect `this`
: Object.defineProperty get function has incorrect `this`
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)
: Jason Orendorff [:jorendorff]
Depends on:
  Show dependency treegraph
Reported: 2012-01-24 10:46 PST by Benjamin Smedberg [:bsmedberg]
Modified: 2015-02-18 04:20 PST (History)
5 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

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 User image Benjamin Smedberg [:bsmedberg] 2012-01-24 10:46:18 PST
I'm filing this bug report from a newsgroup post in

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


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 User image Michael A. Puls II 2012-01-24 11:04:26 PST
Created attachment 591181 [details]
Comment 2 User image Michael A. Puls II 2012-01-24 11:05:59 PST
Created attachment 591182 [details]
Pass/Fail TC
Comment 3 User image 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 User image 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 User image 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.