W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2011

Re: Multiple globals and direct/indirect eval

From: David Bruant <bruant@enseirb-matmeca.fr>
Date: Fri, 04 Mar 2011 14:53:29 +0100
Message-ID: <4D70EED9.8060308@enseirb-matmeca.fr>
To: es-discuss@mozilla.org, whatwg <whatwg@whatwg.org>, public-script-coord@w3.org
[Adding WhatWG and public-script-coord (WebIDL) to the discussion.
Discussion is ongoing :
- Start of thread :
- Strawman by Dave Herman:
http://wiki.ecmascript.org/doku.php?id=strawman:multiple_globals )]


I am wondering if ECMAScript is the right "place" to standardize this.
Web browsers face multiple global object via a mecanism which isn't
under the ECMAScript scope (namely HTMLIFrameElements
which aren't even DOM but HTMLDOM-specific).
Other ECMAScript implementations could face the issue of having several
globals but with other non-HTMLDOM use cases. For that reason, I think
it'd be dangerous for ECMAScript to standardize anything on the topic.

To answer Jeff Walden's final questions, in my opinion, WebIDL would be
a way better place to standardize this. ECMAScript could at most provide
guidelines for ECMAScript implementors who would have to face this issue
(gathering feedback and experience from implementations).


Le 03/03/2011 23:39, Jeff Walden a écrit :
> A few months back I noticed an interesting interaction between how
> direct eval is defined and multiple globals.  What happens if, in one
> global, you call an eval from another global as if it were a direct eval?
>   var indirect = otherGlobal.eval;
>   eval = indirect;
>   print(eval("this") === this);
>   print(indirect("this") === this);
> Standards currently don't say what should happen here because it's
> multiple globals, so what should this do?  IE9 and Opera print false
> both times for this.  Firefox prints true, then false -- but only if
> the global and otherGlobal are from the same origin (so on pages with
> the same scheme/host/port, more or less).  If they're from different
> origins (but have set document.domain to the same value) Firefox too
> prints false.  Chrome and Safari throw an EvalError calling another
> window's eval (for both "direct" and indirect calls) without that
> window as |this| for the call.
> The Chrome/Safari behavior would resurrect the vestigial EvalError, so
> I don't think it makes sense.  It also contradicts the specification
> of the steps in the definition of the eval function.  Firefox's
> behavior is inconsistent and seems not amenable to host-agnostic
> specification as ECMA would require.  Thus we are left with the
> IE9/Opera behavior, which seems sensible and natural to me: an eval
> function should always act in the context of the global from which it
> came.
> What needs to be done to standardize this behavior?  And more
> generally, what needs to be done to begin standardizing multiple
> globals in ECMAScript, including issues like this one?
> Jeff
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
Received on Friday, 4 March 2011 13:54:16 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:44 UTC