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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return ScriptValue(); | 160 return ScriptValue(); |
161 } | 161 } |
162 | 162 |
163 if (block.HasCaught()) { | 163 if (block.HasCaught()) { |
164 v8::Local<v8::Message> message = block.Message(); | 164 v8::Local<v8::Message> message = block.Message(); |
165 state->hadException = true; | 165 state->hadException = true; |
166 state->errorMessage = toWebCoreString(message->Get()); | 166 state->errorMessage = toWebCoreString(message->Get()); |
167 state->lineNumber = message->GetLineNumber(); | 167 state->lineNumber = message->GetLineNumber(); |
168 state->columnNumber = message->GetStartColumn(); | 168 state->columnNumber = message->GetStartColumn(); |
169 state->sourceURL = toWebCoreString(message->GetScriptResourceName()); | 169 state->sourceURL = toWebCoreString(message->GetScriptResourceName()); |
170 if (m_workerGlobalScope->sanitizeScriptError(state->errorMessage, state-
>lineNumber, state->columnNumber, state->sourceURL)) | 170 if (m_workerGlobalScope->shouldSanitizeScriptError(state->sourceURL, Not
SharableCrossOrigin)) |
171 state->exception = throwError(v8GeneralError, state->errorMessage.ut
f8().data(), m_isolate); | 171 state->exception = throwError(v8GeneralError, "Script error.", m_iso
late); |
172 else | 172 else |
173 state->exception = ScriptValue(block.Exception()); | 173 state->exception = ScriptValue(block.Exception()); |
174 | 174 |
175 block.Reset(); | 175 block.Reset(); |
176 } else | 176 } else |
177 state->hadException = false; | 177 state->hadException = false; |
178 | 178 |
179 if (result.IsEmpty() || result->IsUndefined()) | 179 if (result.IsEmpty() || result->IsUndefined()) |
180 return ScriptValue(); | 180 return ScriptValue(); |
181 | 181 |
182 return ScriptValue(result); | 182 return ScriptValue(result); |
183 } | 183 } |
184 | 184 |
185 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, Script
Value* exception) | 185 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, Script
Value* exception) |
186 { | 186 { |
187 if (isExecutionForbidden()) | 187 if (isExecutionForbidden()) |
188 return; | 188 return; |
189 | 189 |
190 WorkerGlobalScopeExecutionState state; | 190 WorkerGlobalScopeExecutionState state; |
191 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos
ition(), &state); | 191 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos
ition(), &state); |
192 if (state.hadException) { | 192 if (state.hadException) { |
193 if (exception) { | 193 if (exception) { |
194 *exception = state.exception; | 194 *exception = state.exception; |
195 } else { | 195 } else { |
196 RefPtr<ErrorEvent> event = ErrorEvent::create(state.errorMessage, st
ate.sourceURL, state.lineNumber, state.columnNumber); | 196 RefPtr<ErrorEvent> event = ErrorEvent::create(state.errorMessage, st
ate.sourceURL, state.lineNumber, state.columnNumber); |
197 m_workerGlobalScope->reportException(event, 0); | 197 m_workerGlobalScope->reportException(event, 0, NotSharableCrossOrigi
n); |
198 } | 198 } |
199 } | 199 } |
200 } | 200 } |
201 | 201 |
202 void WorkerScriptController::scheduleExecutionTermination() | 202 void WorkerScriptController::scheduleExecutionTermination() |
203 { | 203 { |
204 // The mutex provides a memory barrier to ensure that once | 204 // The mutex provides a memory barrier to ensure that once |
205 // termination is scheduled, isExecutionTerminating will | 205 // termination is scheduled, isExecutionTerminating will |
206 // accurately reflect that state when called from another thread. | 206 // accurately reflect that state when called from another thread. |
207 { | 207 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 v8::Handle<v8::Object> global = context->Global(); | 249 v8::Handle<v8::Object> global = context->Global(); |
250 global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::GetTempla
te(context->GetIsolate(), WorkerWorld)); | 250 global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::GetTempla
te(context->GetIsolate(), WorkerWorld)); |
251 // Return 0 if the current executing context is not the worker context. | 251 // Return 0 if the current executing context is not the worker context. |
252 if (global.IsEmpty()) | 252 if (global.IsEmpty()) |
253 return 0; | 253 return 0; |
254 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global)
; | 254 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global)
; |
255 return workerGlobalScope->script(); | 255 return workerGlobalScope->script(); |
256 } | 256 } |
257 | 257 |
258 } // namespace WebCore | 258 } // namespace WebCore |
OLD | NEW |