| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 ScriptState::Scope scope(m_scriptState.get()); | 176 ScriptState::Scope scope(m_scriptState.get()); |
| 177 | 177 |
| 178 if (!m_disableEvalPending.isEmpty()) { | 178 if (!m_disableEvalPending.isEmpty()) { |
| 179 m_scriptState->context()->AllowCodeGenerationFromStrings(false); | 179 m_scriptState->context()->AllowCodeGenerationFromStrings(false); |
| 180 m_scriptState->context()->SetErrorMessageForCodeGenerationFromStrings(v8
String(isolate(), m_disableEvalPending)); | 180 m_scriptState->context()->SetErrorMessageForCodeGenerationFromStrings(v8
String(isolate(), m_disableEvalPending)); |
| 181 m_disableEvalPending = String(); | 181 m_disableEvalPending = String(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 v8::TryCatch block; | 184 v8::TryCatch block; |
| 185 | 185 |
| 186 v8::Handle<v8::Script> compiledScript = V8ScriptRunner::compileScript(script
, fileName, String(), scriptStartPosition, isolate(), cacheHandler, SharableCros
sOrigin, v8CacheOptions); | 186 v8::Local<v8::Script> compiledScript; |
| 187 v8::Local<v8::Value> result = V8ScriptRunner::runCompiledScript(isolate(), c
ompiledScript, &m_workerGlobalScope); | 187 v8::MaybeLocal<v8::Value> maybeResult; |
| 188 if (v8Call(V8ScriptRunner::compileScript(script, fileName, String(), scriptS
tartPosition, isolate(), cacheHandler, SharableCrossOrigin, v8CacheOptions), com
piledScript, block)) |
| 189 maybeResult = V8ScriptRunner::runCompiledScript(isolate(), compiledScrip
t, &m_workerGlobalScope); |
| 188 | 190 |
| 189 if (!block.CanContinue()) { | 191 if (!block.CanContinue()) { |
| 190 forbidExecution(); | 192 forbidExecution(); |
| 191 return ScriptValue(); | 193 return ScriptValue(); |
| 192 } | 194 } |
| 193 | 195 |
| 194 if (block.HasCaught()) { | 196 if (block.HasCaught()) { |
| 195 v8::Local<v8::Message> message = block.Message(); | 197 v8::Local<v8::Message> message = block.Message(); |
| 196 m_globalScopeExecutionState->hadException = true; | 198 m_globalScopeExecutionState->hadException = true; |
| 197 m_globalScopeExecutionState->errorMessage = toCoreString(message->Get())
; | 199 m_globalScopeExecutionState->errorMessage = toCoreString(message->Get())
; |
| 198 m_globalScopeExecutionState->lineNumber = message->GetLineNumber(); | 200 m_globalScopeExecutionState->lineNumber = message->GetLineNumber(); |
| 199 m_globalScopeExecutionState->columnNumber = message->GetStartColumn() +
1; | 201 m_globalScopeExecutionState->columnNumber = message->GetStartColumn() +
1; |
| 200 TOSTRING_DEFAULT(V8StringResource<>, sourceURL, message->GetScriptOrigin
().ResourceName(), ScriptValue()); | 202 TOSTRING_DEFAULT(V8StringResource<>, sourceURL, message->GetScriptOrigin
().ResourceName(), ScriptValue()); |
| 201 m_globalScopeExecutionState->sourceURL = sourceURL; | 203 m_globalScopeExecutionState->sourceURL = sourceURL; |
| 202 m_globalScopeExecutionState->exception = ScriptValue(m_scriptState.get()
, block.Exception()); | 204 m_globalScopeExecutionState->exception = ScriptValue(m_scriptState.get()
, block.Exception()); |
| 203 block.Reset(); | 205 block.Reset(); |
| 204 } else { | 206 } else { |
| 205 m_globalScopeExecutionState->hadException = false; | 207 m_globalScopeExecutionState->hadException = false; |
| 206 } | 208 } |
| 207 | 209 |
| 208 if (result.IsEmpty() || result->IsUndefined()) | 210 v8::Local<v8::Value> result; |
| 211 if (!maybeResult.ToLocal(&result) || result->IsUndefined()) |
| 209 return ScriptValue(); | 212 return ScriptValue(); |
| 210 | 213 |
| 211 return ScriptValue(m_scriptState.get(), result); | 214 return ScriptValue(m_scriptState.get(), result); |
| 212 } | 215 } |
| 213 | 216 |
| 214 bool WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr
WillBeRawPtr<ErrorEvent>* errorEvent, CachedMetadataHandler* cacheHandler, V8Cac
heOptions v8CacheOptions) | 217 bool WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr
WillBeRawPtr<ErrorEvent>* errorEvent, CachedMetadataHandler* cacheHandler, V8Cac
heOptions v8CacheOptions) |
| 215 { | 218 { |
| 216 if (isExecutionForbidden()) | 219 if (isExecutionForbidden()) |
| 217 return false; | 220 return false; |
| 218 | 221 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 284 |
| 282 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe
RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) | 285 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe
RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) |
| 283 { | 286 { |
| 284 const String& errorMessage = errorEvent->message(); | 287 const String& errorMessage = errorEvent->message(); |
| 285 if (m_globalScopeExecutionState) | 288 if (m_globalScopeExecutionState) |
| 286 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent
; | 289 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent
; |
| 287 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(isola
te(), errorMessage)); | 290 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(isola
te(), errorMessage)); |
| 288 } | 291 } |
| 289 | 292 |
| 290 } // namespace blink | 293 } // namespace blink |
| OLD | NEW |