OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 RefPtr<ScriptCallStack> callStack; | 95 RefPtr<ScriptCallStack> callStack; |
96 // Currently stack trace is only collected when inspector is open. | 96 // Currently stack trace is only collected when inspector is open. |
97 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) | 97 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) |
98 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt
ackSizeToCapture, v8::Isolate::GetCurrent()); | 98 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt
ackSizeToCapture, v8::Isolate::GetCurrent()); |
99 | 99 |
100 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); | 100 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); |
101 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin
g(); | 101 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin
g(); |
102 String resource = shouldUseDocumentURL ? firstWindow->document()->url() : to
WebCoreString(resourceName); | 102 String resource = shouldUseDocumentURL ? firstWindow->document()->url() : to
WebCoreString(resourceName); |
103 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; | 103 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; |
104 | 104 |
105 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, messag
e->GetLineNumber(), message->GetStartColumn()); | 105 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, messag
e->GetLineNumber(), message->GetStartColumn(), DOMWrapperWorld::current()); |
106 if (V8DOMWrapper::isDOMWrapper(data)) { | 106 if (V8DOMWrapper::isDOMWrapper(data)) { |
107 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data); | 107 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data); |
108 WrapperTypeInfo* type = toWrapperTypeInfo(obj); | 108 WrapperTypeInfo* type = toWrapperTypeInfo(obj); |
109 if (V8DOMException::info.isSubclass(type)) { | 109 if (V8DOMException::info.isSubclass(type)) { |
110 DOMException* exception = V8DOMException::toNative(obj); | 110 DOMException* exception = V8DOMException::toNative(obj); |
111 if (exception && !exception->messageForConsole().isEmpty()) | 111 if (exception && !exception->messageForConsole().isEmpty()) |
112 event->setUnsanitizedMessage("Uncaught " + exception->toStringFo
rConsole()); | 112 event->setUnsanitizedMessage("Uncaught " + exception->toStringFo
rConsole()); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // Exceptions that occur in error handler should be ignored since in that ca
se | 183 // Exceptions that occur in error handler should be ignored since in that ca
se |
184 // WorkerGlobalScope::reportException will send the exception to the worker
object. | 184 // WorkerGlobalScope::reportException will send the exception to the worker
object. |
185 if (isReportingException) | 185 if (isReportingException) |
186 return; | 186 return; |
187 isReportingException = true; | 187 isReportingException = true; |
188 | 188 |
189 // During the frame teardown, there may not be a valid context. | 189 // During the frame teardown, there may not be a valid context. |
190 if (ScriptExecutionContext* context = getScriptExecutionContext()) { | 190 if (ScriptExecutionContext* context = getScriptExecutionContext()) { |
191 String errorMessage = toWebCoreString(message->Get()); | 191 String errorMessage = toWebCoreString(message->Get()); |
192 String sourceURL = toWebCoreString(message->GetScriptResourceName()); | 192 String sourceURL = toWebCoreString(message->GetScriptResourceName()); |
193 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, m
essage->GetLineNumber(), message->GetStartColumn()); | 193 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, m
essage->GetLineNumber(), message->GetStartColumn(), DOMWrapperWorld::current()); |
194 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; | 194 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; |
195 | 195 |
196 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, v8:
:Isolate::GetCurrent()); | 196 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, v8:
:Isolate::GetCurrent()); |
197 context->reportException(event.release(), 0, corsStatus); | 197 context->reportException(event.release(), 0, corsStatus); |
198 } | 198 } |
199 | 199 |
200 isReportingException = false; | 200 isReportingException = false; |
201 } | 201 } |
202 | 202 |
203 static const int kWorkerMaxStackSize = 500 * 1024; | 203 static const int kWorkerMaxStackSize = 500 * 1024; |
204 | 204 |
205 void V8Initializer::initializeWorker(v8::Isolate* isolate) | 205 void V8Initializer::initializeWorker(v8::Isolate* isolate) |
206 { | 206 { |
207 initializeV8Common(); | 207 initializeV8Common(); |
208 | 208 |
209 v8::V8::AddMessageListener(messageHandlerInWorker); | 209 v8::V8::AddMessageListener(messageHandlerInWorker); |
210 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 210 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
211 | 211 |
212 v8::ResourceConstraints resourceConstraints; | 212 v8::ResourceConstraints resourceConstraints; |
213 uint32_t here; | 213 uint32_t here; |
214 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); | 214 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); |
215 v8::SetResourceConstraints(&resourceConstraints); | 215 v8::SetResourceConstraints(&resourceConstraints); |
216 | 216 |
217 V8PerIsolateData::ensureInitialized(isolate); | 217 V8PerIsolateData::ensureInitialized(isolate); |
218 } | 218 } |
219 | 219 |
220 } // namespace WebCore | 220 } // namespace WebCore |
OLD | NEW |