this !== window in WebConsole




JavaScript Engine
7 years ago
7 years ago


(Reporter: David Bruant, Unassigned)



Firefox Tracking Flags

(Not tracked)


(Whiteboard: DOC: in WebConsole, this !== window and see comment 7)



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

7 years ago
For the record, "Function("return this;").call();" is a way to retrieve the global object in both non/strict mode.
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...
And in particular, in a web page the script you quote returns true, as you can check.

Comment 4

7 years ago
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.
> 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")|.
Last Resolved: 7 years ago
Resolution: --- → WORKSFORME

Comment 6

7 years ago
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.
Keywords: dev-doc-needed
Summary: globalObject !== window → this !== window in WebConsole
Whiteboard: DOC: in WebConsole, this !== window
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.


7 years ago
Whiteboard: DOC: in WebConsole, this !== window → DOC: in WebConsole, this !== window and see comment 7
I filed bug 641655 on the standard class stuff.
Added a note to:
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.