[Webkit-unassigned] [Bug 35722] "this" context is lost when eval'd from remote script
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Mar 8 16:12:07 PST 2010
https://bugs.webkit.org/show_bug.cgi?id=35722
--- Comment #4 from Geoffrey Garen <ggaren at apple.com> 2010-03-08 16:12:07 PST ---
I don't think this is a particularly bad bug. Safari's behavior matches
Chrome's and Opera's, though it seems to differ from the current version of the
ES5 spec.
Here is a reduced test showing the behavior difference:
(function () { window.eval('log(this)'); }).call("a string");
Firefox prints "a string", which Safari, Chrome, and Opera print "[object
DOMWindow]".
If you change "window.eval" to "eval", Safari, Chrome, and Opera print "a
string".
The difference in behavior comes down to a question of what syntax counts as a
use of the built-in eval operator, as opposed to a call to the built-in eval
function. (Only uses of the built-in eval operator inherit local bindings like
'this'.)
In Firefox and the current draft of the ES5 spec, any MemberExpression
involving the keyword 'eval' counts as a use of the built-in eval operator. In
Safari, Chrome, and Opera, only the Identifier 'eval' counts.
The more expansive rule in the ES5 spec seems unwarranted, given the complexity
it introduces, but I don't see too much harm in implementing it if anyone feels
the urge.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list