void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, NakedPtr<JSC::Exception>& returnedException) { if (isExecutionForbidden()) return; initScriptIfNeeded(); ExecState* exec = m_workerGlobalScopeWrapper->globalExec(); JSLockHolder lock(exec); JSC::evaluate(exec, sourceCode.jsSourceCode(), m_workerGlobalScopeWrapper->globalThis(), returnedException); VM& vm = exec->vm(); if ((returnedException && isTerminatedExecutionException(returnedException)) || isTerminatingExecution()) { forbidExecution(); return; } if (returnedException) { String errorMessage; int lineNumber = 0; int columnNumber = 0; String sourceURL = sourceCode.url().string(); if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, sourceCode.cachedScript())) { vm.throwException(exec, createError(exec, errorMessage.impl())); returnedException = vm.exception(); vm.clearException(); } } }
void WorkerScriptController::disableEval(const String& errorMessage) { initScriptIfNeeded(); JSLockHolder lock(vm()); m_workerGlobalScopeWrapper->setEvalEnabled(false, errorMessage); }
void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, Deprecated::ScriptValue* exception) { if (isExecutionForbidden()) return; initScriptIfNeeded(); ExecState* exec = m_workerGlobalScopeWrapper->globalExec(); JSLockHolder lock(exec); JSValue evaluationException; JSC::evaluate(exec, sourceCode.jsSourceCode(), m_workerGlobalScopeWrapper.get(), &evaluationException); if ((evaluationException && isTerminatedExecutionException(evaluationException)) || m_workerGlobalScopeWrapper->vm().watchdog.didFire()) { forbidExecution(); return; } if (evaluationException) { String errorMessage; int lineNumber = 0; int columnNumber = 0; String sourceURL = sourceCode.url().string(); if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, sourceCode.cachedScript())) *exception = Deprecated::ScriptValue(*m_vm, exec->vm().throwException(exec, createError(exec, errorMessage.impl()))); else *exception = Deprecated::ScriptValue(*m_vm, evaluationException); } }
void WorkerScriptController::disableEval() { initScriptIfNeeded(); JSLock lock(SilenceAssertionsOnly); m_workerContextWrapper->setEvalEnabled(false); }
void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, ScriptValue* exception) { if (isExecutionForbidden()) return; initScriptIfNeeded(); ExecState* exec = m_workerContextWrapper->globalExec(); JSLockHolder lock(exec); m_workerContextWrapper->globalData().timeoutChecker.start(); JSValue evaluationException; JSC::evaluate(exec, sourceCode.jsSourceCode(), m_workerContextWrapper.get(), &evaluationException); m_workerContextWrapper->globalData().timeoutChecker.stop(); if ((evaluationException && isTerminatedExecutionException(evaluationException)) || m_workerContextWrapper->globalData().terminator.shouldTerminate()) { forbidExecution(); return; } if (evaluationException) { String errorMessage; int lineNumber = 0; String sourceURL = sourceCode.url().string(); if (m_workerContext->sanitizeScriptError(errorMessage, lineNumber, sourceURL)) *exception = ScriptValue(*m_globalData, throwError(exec, createError(exec, errorMessage.impl()))); else *exception = ScriptValue(*m_globalData, evaluationException); } }
ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode) { { MutexLocker lock(m_sharedDataMutex); if (m_executionForbidden) return noValue(); } initScriptIfNeeded(); JSLock lock(false); ExecState* exec = m_workerContextWrapper->globalExec(); m_workerContextWrapper->startTimeoutCheck(); Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper); m_workerContextWrapper->stopTimeoutCheck(); m_workerContext->thread()->messagingProxy()->reportWorkerThreadActivity(m_workerContext->hasPendingActivity()); if (comp.complType() == Normal || comp.complType() == ReturnValue) return comp.value(); if (comp.complType() == Throw) reportException(exec, comp.value()); return noValue(); }
ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, ScriptValue* exception) { if (isExecutionForbidden()) return ScriptValue(); initScriptIfNeeded(); JSLock lock(SilenceAssertionsOnly); ExecState* exec = m_workerContextWrapper->globalExec(); m_workerContextWrapper->globalData().timeoutChecker.start(); Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper.get()); m_workerContextWrapper->globalData().timeoutChecker.stop(); ComplType completionType = comp.complType(); if (completionType == Terminated || m_workerContextWrapper->globalData().terminator.shouldTerminate()) { forbidExecution(); return ScriptValue(); } if (completionType == JSC::Normal || completionType == ReturnValue) return ScriptValue(*m_globalData, comp.value()); if (completionType == Throw) { String errorMessage; int lineNumber = 0; String sourceURL = sourceCode.url().string(); if (m_workerContext->sanitizeScriptError(errorMessage, lineNumber, sourceURL)) *exception = ScriptValue(*m_globalData, throwError(exec, createError(exec, errorMessage.impl()))); else *exception = ScriptValue(*m_globalData, comp.value()); } return ScriptValue(); }
JSValue* KJSProxy::evaluate(const String& filename, int baseLine, const String& str, Node* n) { // evaluate code. Returns the JS return value or 0 // if there was none, an error occured or the type couldn't be converted. initScriptIfNeeded(); // inlineCode is true for <a href="javascript:doSomething()"> // and false for <script>doSomething()</script>. Check if it has the // expected value in all cases. // See smart window.open policy for where this is used. bool inlineCode = filename.isNull(); m_script->setInlineCode(inlineCode); JSLock lock; JSValue* thisNode = n ? Window::retrieve(m_frame) : toJS(m_script->globalExec(), n); m_script->startTimeoutCheck(); Completion comp = m_script->evaluate(filename, baseLine, reinterpret_cast<const KJS::UChar*>(str.characters()), str.length(), thisNode); m_script->stopTimeoutCheck(); if (comp.complType() == Normal || comp.complType() == ReturnValue) return comp.value(); if (comp.complType() == Throw) { UString errorMessage = comp.value()->toString(m_script->globalExec()); int lineNumber = comp.value()->toObject(m_script->globalExec())->get(m_script->globalExec(), "line")->toInt32(m_script->globalExec()); UString sourceURL = comp.value()->toObject(m_script->globalExec())->get(m_script->globalExec(), "sourceURL")->toString(m_script->globalExec()); if (Page* page = m_frame->page()) page->chrome()->addMessageToConsole(errorMessage, lineNumber, sourceURL); } return 0; }
JSValue* ScriptController::evaluate(const String& filename, int baseLine, const String& str) { // 11/09/09 CSidhall - Added notify process start to user NOTIFY_PROCESS_STATUS(EA::WebKit::kVProcessTypeScript, EA::WebKit::kVProcessStatusStarted); // evaluate code. Returns the JS return value or 0 // if there was none, an error occured or the type couldn't be converted. initScriptIfNeeded(); // inlineCode is true for <a href="javascript:doSomething()"> // and false for <script>doSomething()</script>. Check if it has the // expected value in all cases. // See smart window.open policy for where this is used. ExecState* exec = m_windowShell->window()->globalExec(); m_processingInlineCode = filename.isNull(); JSLock lock; // Evaluating the JavaScript could cause the frame to be deallocated // so we start the keep alive timer here. m_frame->keepAlive(); m_windowShell->window()->startTimeoutCheck(); Completion comp = Interpreter::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), filename, baseLine, StringSourceProvider::create(str), m_windowShell); m_windowShell->window()->stopTimeoutCheck(); NOTIFY_PROCESS_STATUS(EA::WebKit::kVProcessTypeScript, EA::WebKit::kVProcessStatusEnded); if (comp.complType() == Normal || comp.complType() == ReturnValue) { m_processingInlineCode = false; return comp.value(); } if (comp.complType() == Throw) { UString errorMessage = comp.value()->toString(exec); int lineNumber = comp.value()->toObject(exec)->get(exec, Identifier(exec, "line"))->toInt32(exec); UString sourceURL = comp.value()->toObject(exec)->get(exec, Identifier(exec, "sourceURL"))->toString(exec); m_frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, lineNumber, sourceURL); } m_processingInlineCode = false; return 0; }
ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) { // evaluate code. Returns the JS return value or 0 // if there was none, an error occured or the type couldn't be converted. const SourceCode& jsSourceCode = sourceCode.jsSourceCode(); initScriptIfNeeded(); // inlineCode is true for <a href="javascript:doSomething()"> // and false for <script>doSomething()</script>. Check if it has the // expected value in all cases. // See smart window.open policy for where this is used. ExecState* exec = m_windowShell->window()->globalExec(); const String* savedSourceURL = m_sourceURL; String sourceURL = jsSourceCode.provider()->url(); m_sourceURL = &sourceURL; JSLock lock(false); // Evaluating the JavaScript could cause the frame to be deallocated // so we start the keep alive timer here. m_frame->keepAlive(); m_windowShell->window()->startTimeoutCheck(); Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, m_windowShell); m_windowShell->window()->stopTimeoutCheck(); if (comp.complType() == Normal || comp.complType() == ReturnValue) { m_sourceURL = savedSourceURL; return comp.value(); } if (comp.complType() == Throw) reportException(exec, comp.value()); m_sourceURL = savedSourceURL; return noValue(); }
ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, ScriptValue* exception) { { MutexLocker lock(m_sharedDataMutex); if (m_executionForbidden) return JSValue(); } initScriptIfNeeded(); JSLock lock(SilenceAssertionsOnly); ExecState* exec = m_workerContextWrapper->globalExec(); m_workerContextWrapper->globalData().timeoutChecker.start(); Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper); m_workerContextWrapper->globalData().timeoutChecker.stop(); if (comp.complType() == Normal || comp.complType() == ReturnValue) return comp.value(); if (comp.complType() == Throw) *exception = comp.value(); return JSValue(); }
void WorkerScriptController::attachDebugger(JSC::Debugger* debugger) { initScriptIfNeeded(); debugger->attach(m_workerGlobalScopeWrapper->globalObject()); }
PassRefPtr<EventListener> ScriptController::createSVGEventHandler(const String& functionName, const String& code, Node* node) { initScriptIfNeeded(); JSLock lock; return JSSVGLazyEventListener::create(functionName, code, m_windowShell->window(), node, m_handlerLineno); }
PassRefPtr<EventListener> ScriptController::createInlineEventListener(const String& functionName, const String& code, Node* node) { initScriptIfNeeded(); JSLock lock(false); return JSLazyEventListener::create(JSLazyEventListener::HTMLLazyEventListener, functionName, code, m_windowShell->window(), node, m_handlerLineno); }
EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node* node) { initScriptIfNeeded(); JSLock lock; return new JSLazyEventListener(functionName, code, Window::retrieveWindow(m_frame), node, m_handlerLineno); }
ScriptInterpreter* KJSProxy::interpreter() { initScriptIfNeeded(); assert(m_script); return m_script.get(); }