Changeset 25534 in webkit


Ignore:
Timestamp:
Sep 13, 2007 6:54:12 AM (17 years ago)
Author:
antti
Message:

JavaScriptCore:

Reviewed by Geoff, Maciej.


Fix <rdar://problem/5445058>
REGRESSION: Unable to upload picture to eBay auction due to domain security check


eBay uses window.eval() between windows. In Firefox window.eval() switches execution
and security context to the target window, something WebKit did not do. With WebKit
security tightening in r24781, this broke picture uploads.


Fix by making WebKit switch context in window.eval().


  • kjs/Context.cpp: (KJS::Context::Context): (KJS::Context::~Context):
  • kjs/context.h: Save and restore interpreter context independently from calling context.


  • kjs/function.cpp: (KJS::GlobalFuncImp::callAsFunction): If eval is called for global object different than current one, switch execution context to that object and push it to scope.

LayoutTests:

Reviewed by Geoff, Maciej.


Test for <rdar://problem/5445058>
REGRESSION: Unable to upload picture to eBay auction due to domain security check

  • fast/js/window-eval-context-expected.txt: Added.
  • fast/js/window-eval-context.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r25527 r25534  
     12007-09-12  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Geoff, Maciej.
     4       
     5        Fix <rdar://problem/5445058>
     6        REGRESSION: Unable to upload picture to eBay auction due to domain security check
     7       
     8        eBay uses window.eval() between windows. In Firefox window.eval() switches execution
     9        and security context to the target window, something WebKit did not do. With WebKit
     10        security tightening in r24781, this broke picture uploads.
     11       
     12        Fix by making WebKit switch context in window.eval().
     13       
     14        * kjs/Context.cpp:
     15        (KJS::Context::Context):
     16        (KJS::Context::~Context):
     17        * kjs/context.h:
     18        Save and restore interpreter context independently from calling context.
     19       
     20        * kjs/function.cpp:
     21        (KJS::GlobalFuncImp::callAsFunction):
     22        If eval is called for global object different than current one, switch execution context
     23        to that object and push it to scope.
     24
    1252007-09-12  Sam Weinig  <sam@webkit.org>
    226
  • trunk/JavaScriptCore/kjs/Context.cpp

    r21019 r25534  
    3232                 FunctionImp* func, const List* args)
    3333    : m_interpreter(interpreter)
     34    , m_savedContext(interpreter->context())
    3435    , m_currentBody(currentBody)
    3536    , m_function(func)
     
    8485Context::~Context()
    8586{
    86     m_interpreter->setContext(m_callingContext);
     87    m_interpreter->setContext(m_savedContext);
    8788
    8889    // The arguments list is only needed to potentially create the  arguments object,
  • trunk/JavaScriptCore/kjs/context.h

    r21889 r25534  
    130130    Interpreter* m_interpreter;
    131131    Context* m_callingContext;
     132    Context* m_savedContext;
    132133    FunctionBodyNode* m_currentBody;
    133134    ExecState* m_execState;
  • trunk/JavaScriptCore/kjs/function.cpp

    r24394 r25534  
    771771}
    772772
    773 JSValue* GlobalFuncImp::callAsFunction(ExecState* exec, JSObject* /*thisObj*/, const List& args)
     773JSValue* GlobalFuncImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    774774{
    775775  JSValue* res = jsUndefined();
     
    818818          return throwError(exec, SyntaxError, errMsg, errLine, sid, NULL);
    819819
     820        bool switchGlobal = exec->dynamicInterpreter()->isGlobalObject(thisObj) && thisObj != exec->dynamicInterpreter()->globalObject();
     821         
    820822        // enter a new execution context
     823        Interpreter* interpreter = switchGlobal ? exec->dynamicInterpreter()->interpreterForGlobalObject(thisObj) : exec->dynamicInterpreter();
    821824        JSObject* thisVal = static_cast<JSObject*>(exec->context()->thisValue());
    822         Context ctx(exec->dynamicInterpreter()->globalObject(),
    823                        exec->dynamicInterpreter(),
     825        Context ctx(interpreter->globalObject(),
     826                       interpreter,
    824827                       thisVal,
    825828                       progNode.get(),
    826829                       EvalCode,
    827830                       exec->context());
    828         ExecState newExec(exec->dynamicInterpreter(), &ctx);
     831        ExecState newExec(interpreter, &ctx);
    829832        if (exec->hadException())
    830833            newExec.setException(exec->exception());
    831834        ctx.setExecState(&newExec);
     835         
     836        if (switchGlobal)
     837            ctx.pushScope(thisObj);
    832838       
    833839        // execute the code
    834840        progNode->processVarDecls(&newExec);
    835841        Completion c = progNode->execute(&newExec);
     842         
     843        if (switchGlobal)
     844            ctx.popScope();
    836845
    837846        // if an exception occured, propogate it back to the previous execution object
  • trunk/LayoutTests/ChangeLog

    r25531 r25534  
     12007-09-12  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Geoff, Maciej.
     4       
     5        Test for <rdar://problem/5445058>
     6        REGRESSION: Unable to upload picture to eBay auction due to domain security check
     7
     8        * fast/js/window-eval-context-expected.txt: Added.
     9        * fast/js/window-eval-context.html: Added.
     10
    1112007-09-12  John Seif <johneseif@gmail.com>
    212
Note: See TracChangeset for help on using the changeset viewer.