Closed Bug 641629 Opened 14 years ago Closed 14 years ago

this !== window in WebConsole

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: bruant.d, Unassigned)

Details

(Keywords: dev-doc-complete, Whiteboard: DOC: in WebConsole, this !== window and see comment 7)

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 15.2.3.4-4-1 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
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.
I have indeed tested on the WebConsole. Regardless, the test was run and failed in the normal environment (from http://test262.ecmascript.org/).
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 15.2.3.4-4-1 in test262 fails because we lazily resolve standard classes, not because of anything to do with |new Function("return this")|.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → WORKSFORME
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
Resolution: WORKSFORME → INVALID
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.
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:

https://developer.mozilla.org/en/Using_the_Web_Console#Basic_usage
You need to log in before you can comment on or make changes to this bug.