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->shouldSanitizeScriptError(state->sourceURL, Not SharableCrossOrigin)) | 170 state->exception = ScriptValue(block.Exception()); |
do-not-use
2013/08/07 18:05:05
Actually, it looks like we can remove WorkerGlobal
Mike West
2013/08/08 05:03:15
In this patch, yes. I plan to follow up with a pat
do-not-use
2013/08/08 06:25:00
I think it is fine to keep it if you plan to use i
| |
171 state->exception = throwError(v8GeneralError, "Script error.", m_iso late); | |
172 else | |
173 state->exception = ScriptValue(block.Exception()); | |
174 | 171 |
175 block.Reset(); | 172 block.Reset(); |
176 } else | 173 } else |
177 state->hadException = false; | 174 state->hadException = false; |
178 | 175 |
179 if (result.IsEmpty() || result->IsUndefined()) | 176 if (result.IsEmpty() || result->IsUndefined()) |
180 return ScriptValue(); | 177 return ScriptValue(); |
181 | 178 |
182 return ScriptValue(result); | 179 return ScriptValue(result); |
183 } | 180 } |
184 | 181 |
185 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, Script Value* exception) | 182 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr <ErrorEvent>* errorEvent) |
186 { | 183 { |
187 if (isExecutionForbidden()) | 184 if (isExecutionForbidden()) |
188 return; | 185 return; |
189 | 186 |
190 WorkerGlobalScopeExecutionState state; | 187 WorkerGlobalScopeExecutionState state; |
191 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), &state); | 188 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), &state); |
192 if (state.hadException) { | 189 if (state.hadException) { |
193 if (exception) { | 190 if (errorEvent) { |
194 *exception = state.exception; | 191 *errorEvent = m_workerGlobalScope->shouldSanitizeScriptError(state.s ourceURL, NotSharableCrossOrigin) ? |
192 ErrorEvent::createSanitizedError() : ErrorEvent::create(state.er rorMessage, state.sourceURL, state.lineNumber, state.columnNumber); | |
195 } else { | 193 } else { |
196 RefPtr<ErrorEvent> event = ErrorEvent::create(state.errorMessage, st ate.sourceURL, state.lineNumber, state.columnNumber); | 194 ASSERT(!m_workerGlobalScope->shouldSanitizeScriptError(state.sourceU RL, NotSharableCrossOrigin)); |
195 RefPtr<ErrorEvent> event = m_errorEventFromImportedScript ? m_errorE ventFromImportedScript.release() : ErrorEvent::create(state.errorMessage, state. sourceURL, state.lineNumber, state.columnNumber); | |
196 m_errorEventFromImportedScript.clear(); | |
do-not-use
2013/08/07 18:05:05
This line looks superfluous since you release() th
Mike West
2013/08/08 05:03:15
Indeed.
| |
197 m_workerGlobalScope->reportException(event, 0, NotSharableCrossOrigi n); | 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. |
(...skipping 21 matching lines...) Expand all Loading... | |
228 { | 228 { |
229 ASSERT(m_workerGlobalScope->isContextThread()); | 229 ASSERT(m_workerGlobalScope->isContextThread()); |
230 return m_executionForbidden; | 230 return m_executionForbidden; |
231 } | 231 } |
232 | 232 |
233 void WorkerScriptController::disableEval(const String& errorMessage) | 233 void WorkerScriptController::disableEval(const String& errorMessage) |
234 { | 234 { |
235 m_disableEvalPending = errorMessage; | 235 m_disableEvalPending = errorMessage; |
236 } | 236 } |
237 | 237 |
238 void WorkerScriptController::setException(const ScriptValue& exception) | 238 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtr<Error Event> errorEvent) |
239 { | 239 { |
240 throwError(exception.v8Value()); | 240 m_errorEventFromImportedScript = errorEvent; |
241 throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImp ortedScript->message(), m_isolate)); | |
241 } | 242 } |
242 | 243 |
243 WorkerScriptController* WorkerScriptController::controllerForContext() | 244 WorkerScriptController* WorkerScriptController::controllerForContext() |
244 { | 245 { |
245 // Happens on frame destruction, check otherwise GetCurrent() will crash. | 246 // Happens on frame destruction, check otherwise GetCurrent() will crash. |
246 if (!v8::Context::InContext()) | 247 if (!v8::Context::InContext()) |
247 return 0; | 248 return 0; |
248 v8::Handle<v8::Context> context = v8::Context::GetCurrent(); | 249 v8::Handle<v8::Context> context = v8::Context::GetCurrent(); |
249 v8::Handle<v8::Object> global = context->Global(); | 250 v8::Handle<v8::Object> global = context->Global(); |
250 global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::GetTempla te(context->GetIsolate(), WorkerWorld)); | 251 global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::GetTempla te(context->GetIsolate(), WorkerWorld)); |
251 // Return 0 if the current executing context is not the worker context. | 252 // Return 0 if the current executing context is not the worker context. |
252 if (global.IsEmpty()) | 253 if (global.IsEmpty()) |
253 return 0; | 254 return 0; |
254 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global) ; | 255 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global) ; |
255 return workerGlobalScope->script(); | 256 return workerGlobalScope->script(); |
256 } | 257 } |
257 | 258 |
258 } // namespace WebCore | 259 } // namespace WebCore |
OLD | NEW |