Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: Source/bindings/core/v8/WorkerScriptController.cpp

Issue 404513002: Propagate nested importScripts() error events outwards. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clear error event before entering an importScripts() evaluation. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 return ScriptValue(m_scriptState.get(), result); 197 return ScriptValue(m_scriptState.get(), result);
198 } 198 }
199 199
200 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr WillBeRawPtr<ErrorEvent>* errorEvent) 200 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr WillBeRawPtr<ErrorEvent>* errorEvent)
201 { 201 {
202 if (isExecutionForbidden()) 202 if (isExecutionForbidden())
203 return; 203 return;
204 204
205 WorkerGlobalScopeExecutionState state; 205 WorkerGlobalScopeExecutionState state;
206 m_errorEventFromImportedScript.clear();
haraken 2014/07/17 15:19:05 Is it possible that m_errorEventFromImportedScript
sof 2014/07/17 15:22:17 It won't be cleared whenever a previous (not neste
haraken 2014/07/17 15:47:24 Then does it mean that a persistent handle to the
sof 2014/07/17 15:53:19 Yes, or via a RefPtr non-Oilpan if that exception
haraken 2014/07/17 15:58:54 I'm a bit afraid that it will cause leaks. Why can
sof 2014/07/17 18:13:11 I'll have another look if we can tidy this up here
sof 2014/07/17 22:05:31 Reworked a bit to let these ErrorEvents be stack a
206 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), &state); 207 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), &state);
207 if (state.hadException) { 208 if (state.hadException) {
208 if (errorEvent) { 209 if (errorEvent) {
209 *errorEvent = m_workerGlobalScope.shouldSanitizeScriptError(state.so urceURL, NotSharableCrossOrigin) ? 210 if (m_errorEventFromImportedScript) {
210 ErrorEvent::createSanitizedError(m_world.get()) : ErrorEvent::cr eate(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get()); 211 // Propagate inner error event outwards.
212 *errorEvent = m_errorEventFromImportedScript.release();
213 return;
214 }
215 if (m_workerGlobalScope.shouldSanitizeScriptError(state.sourceURL, N otSharableCrossOrigin))
216 *errorEvent = ErrorEvent::createSanitizedError(m_world.get());
217 else
218 *errorEvent = ErrorEvent::create(state.errorMessage, state.sourc eURL, state.lineNumber, state.columnNumber, m_world.get());
211 V8ErrorHandler::storeExceptionOnErrorEventWrapper(errorEvent->get(), state.exception.v8Value(), m_scriptState->context()->Global(), m_isolate); 219 V8ErrorHandler::storeExceptionOnErrorEventWrapper(errorEvent->get(), state.exception.v8Value(), m_scriptState->context()->Global(), m_isolate);
212 } else { 220 } else {
213 ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceUR L, NotSharableCrossOrigin)); 221 ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceUR L, NotSharableCrossOrigin));
214 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr; 222 RefPtrWillBeRawPtr<ErrorEvent> event = nullptr;
215 if (m_errorEventFromImportedScript) { 223 if (m_errorEventFromImportedScript)
216 event = m_errorEventFromImportedScript.release(); 224 event = m_errorEventFromImportedScript.release();
217 } else { 225 else
218 event = ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get()); 226 event = ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get());
219 }
220 m_workerGlobalScope.reportException(event, nullptr, NotSharableCross Origin); 227 m_workerGlobalScope.reportException(event, nullptr, NotSharableCross Origin);
221 } 228 }
222 } 229 }
223 } 230 }
224 231
225 void WorkerScriptController::scheduleExecutionTermination() 232 void WorkerScriptController::scheduleExecutionTermination()
226 { 233 {
227 // The mutex provides a memory barrier to ensure that once 234 // The mutex provides a memory barrier to ensure that once
228 // termination is scheduled, isExecutionTerminating will 235 // termination is scheduled, isExecutionTerminating will
229 // accurately reflect that state when called from another thread. 236 // accurately reflect that state when called from another thread.
(...skipping 21 matching lines...) Expand all
251 { 258 {
252 ASSERT(m_workerGlobalScope.isContextThread()); 259 ASSERT(m_workerGlobalScope.isContextThread());
253 return m_executionForbidden; 260 return m_executionForbidden;
254 } 261 }
255 262
256 void WorkerScriptController::disableEval(const String& errorMessage) 263 void WorkerScriptController::disableEval(const String& errorMessage)
257 { 264 {
258 m_disableEvalPending = errorMessage; 265 m_disableEvalPending = errorMessage;
259 } 266 }
260 267
261 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent) 268 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState)
262 { 269 {
263 m_errorEventFromImportedScript = errorEvent; 270 m_errorEventFromImportedScript = errorEvent;
264 throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImp ortedScript->message(), m_isolate), m_isolate); 271 exceptionState.rethrowV8Exception(V8ThrowException::createError(v8GeneralErr or, m_errorEventFromImportedScript->message(), m_isolate));
265 } 272 }
266 273
267 } // namespace WebCore 274 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/WorkerScriptController.h ('k') | Source/core/workers/WorkerGlobalScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698