Last Comment Bug 641629 - this !== window in WebConsole
: this !== window in WebConsole
DOC: in WebConsole, this !== window a...
: dev-doc-complete
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: x86 Linux
: -- normal (vote)
: ---
Assigned To: general
: Jason Orendorff [:jorendorff]
Depends on:
  Show dependency treegraph
Reported: 2011-03-14 13:41 PDT by David Bruant
Modified: 2011-03-15 12:46 PDT (History)
3 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description David Bruant 2011-03-14 13:41:23 PDT
User-Agent:       Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/4.0
Build Identifier: FF4RC1

Test case:
var globalObject = Function("return this;").call();
window === globalObject;
true in latest Chrome and Opera.
false in FF4RC1. 

I have noticed it because Object.getOwnPropertyNames gave different results.
I have noticed it after noticing that Test262 Test failed. The problem is that Error doesn't show up on as own keys. However, it's weird because while testing on the WebConsole several times, I have reproduced the non-appearance of all native built-in Errors, but at some point, they were listed.

Reproducible: Always
Comment 1 David Bruant 2011-03-14 13:56:21 PDT
For the record, "Function("return this;").call();" is a way to retrieve the global object in both non/strict mode.
Comment 2 Boris Zbarsky [:bz] (still a bit busy) 2011-03-14 13:57:30 PDT
You're testing this in the web console, aren't you?  In the web console |this| is not the same thing as |window|.

This should not cause any Test262 tests to fail unless you're running them in the web console...
Comment 3 Boris Zbarsky [:bz] (still a bit busy) 2011-03-14 13:58:24 PDT
And in particular, in a web page the script you quote returns true, as you can check.
Comment 4 David Bruant 2011-03-14 14:05:23 PDT
I have indeed tested on the WebConsole. Regardless, the test was run and failed in the normal environment (from
As said, at some point, on the web console. in neither of both object were present native Error built-in. However, this isn't consistent. At some point, they re-appeared.
Comment 5 Boris Zbarsky [:bz] (still a bit busy) 2011-03-14 14:32:27 PDT
> I have indeed tested on the WebConsole.

In WebConsole, |window| is the prototype of |this|.

> Regardless, the test was run and failed in the normal environment

I can't reproduce this.  Not with a javascript: URI, not in a <script> in an HTML page. 

Test in test262 fails because we lazily resolve standard classes, not because of anything to do with |new Function("return this")|.
Comment 6 David Bruant 2011-03-14 14:43:35 PDT
Should I report another bug then? You seem to know the cause, is there already a bug for this?

I change status as 'invalid' since this bug was due to the fact I didn't know about the this keyword in web console. 
I add a dev-doc-needed keyword too.
And I changed the title to make it more easily searchable.
Comment 7 Boris Zbarsky [:bz] (still a bit busy) 2011-03-14 14:46:08 PDT
Jeff promised to file a bug about the standard class stuff, since he can describe it better than I can.

As a web console bug this is invalid, yes.  The idea is to allow the user to define variables in the web console without polluting the page namespace.
Comment 8 Jeff Walden [:Waldo] (remove +bmo to email) 2011-03-14 14:52:28 PDT
I filed bug 641655 on the standard class stuff.
Comment 9 Eric Shepherd [:sheppy] 2011-03-15 12:46:45 PDT
Added a note to:

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