Ignore:
Timestamp:
Mar 7, 2008, 11:46:33 AM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

Reviewed by Darin Adler.


Fixed <rdar://problem/5689093> Stricter (ES4) eval semantics


The basic rule is:


  • "eval(s)" is treated as an operator that gives the ES3 eval behavior.

... but only if there is no overriding declaration of "eval" in scope.

  • All other invocations treat eval as a function that evaluates a script in the context of its "this" object.

... but if its "this" object is not the global object it was
originally associated with, eval throws an exception.


Because only expressions of the form "eval(s)" have access to local
scope, the compiler can now statically determine whether a function
needs local scope to be dynamic.

  • kjs/nodes.h: Added FunctionCallEvalNode. It works just like FuncationCallResolveNode, except it statically indicates that the node may execute eval in the ES3 way.
  • kjs/nodes.cpp:
  • kjs/nodes2string.cpp:
  • tests/mozilla/expected.html: This patch happens to fix a Mozilla JS test, but it's a bit of a pyrrhic victory. The test intends to test Mozilla's generic API for calling eval on any object, but, in reality, we only support calling eval on the global object.

LayoutTests:

Reviewed by Darin Adler.

Tests for <rdar://problem/5689093> Stricter (ES4) eval semantics


  • fast/js/eval-cross-window-expected.txt: Added.
  • fast/js/eval-cross-window.html: Added.
  • fast/js/eval-keyword-vs-function-expected.txt: Added.
  • fast/js/eval-keyword-vs-function.html: Added.
  • fast/js/eval-overriding-expected.txt: Added.
  • fast/js/eval-overriding.html: Added.


Tests to make sure not to regress security:

  • http/tests/security/resources/xss-eval2.html: Added.
  • http/tests/security/resources/xss-eval3.html: Added.
  • http/tests/security/xss-eval-expected.txt: Added.
  • http/tests/security/xss-eval.html: Added.

I removed these tests because we no longer match the behavior they
expected, and the new tests are more comprehensive:


  • fast/js/window-eval-context-expected.txt: Removed.
  • fast/js/window-eval-context.html: Removed.
  • fast/js/window-eval-tearoff-expected.txt: Removed.
  • fast/js/window-eval-tearoff.html: Removed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r30534 r30871  
    4949    class ObjectObjectImp;
    5050    class ObjectPrototype;
     51    class PrototypeReflexiveFunction;
    5152    class RangeError;
    5253    class RangeErrorPrototype;
     
    110111            NativeErrorImp* URIErrorConstructor;
    111112
     113            PrototypeReflexiveFunction* evalFunction;
     114
    112115            ObjectPrototype* objectPrototype;
    113116            FunctionPrototype* functionPrototype;
     
    125128            NativeErrorPrototype* typeErrorPrototype;
    126129            NativeErrorPrototype* URIErrorPrototype;
    127 
     130           
    128131            SymbolTable inlineSymbolTable;
    129132
     
    182185        NativeErrorImp* URIErrorConstructor() const { return d()->URIErrorConstructor; }
    183186
     187        PrototypeReflexiveFunction* evalFunction() const { return d()->evalFunction; }
     188
    184189        ObjectPrototype* objectPrototype() const { return d()->objectPrototype; }
    185190        FunctionPrototype* functionPrototype() const { return d()->functionPrototype; }
Note: See TracChangeset for help on using the changeset viewer.