this !== window in WebConsole

RESOLVED INVALID

Status

()

Core
JavaScript Engine
RESOLVED INVALID
6 years ago
6 years ago

People

(Reporter: David Bruant, Unassigned)

Tracking

({dev-doc-complete})

Firefox Tracking Flags

(Not tracked)

Details

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

(Reporter)

Description

6 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 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
(Reporter)

Comment 1

6 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.
(Reporter)

Comment 4

6 years ago
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
Last Resolved: 6 years ago
Resolution: --- → WORKSFORME
(Reporter)

Comment 6

6 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
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.
(Reporter)

Updated

6 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:

https://developer.mozilla.org/en/Using_the_Web_Console#Basic_usage
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.