| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 88 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 89 // If called during context initialization, there will be no entered context
. | 89 // If called during context initialization, there will be no entered context
. |
| 90 v8::Handle<v8::Context> enteredContext = isolate->GetEnteredContext(); | 90 v8::Handle<v8::Context> enteredContext = isolate->GetEnteredContext(); |
| 91 if (enteredContext.IsEmpty()) | 91 if (enteredContext.IsEmpty()) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 DOMWindow* firstWindow = toDOMWindow(enteredContext); | 94 DOMWindow* firstWindow = toDOMWindow(enteredContext); |
| 95 if (!firstWindow->isCurrentlyDisplayedInFrame()) | 95 if (!firstWindow->isCurrentlyDisplayedInFrame()) |
| 96 return; | 96 return; |
| 97 | 97 |
| 98 String errorMessage = toWebCoreString(message->Get()); | 98 String errorMessage = toCoreString(message->Get()); |
| 99 | 99 |
| 100 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); | 100 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); |
| 101 RefPtr<ScriptCallStack> callStack; | 101 RefPtr<ScriptCallStack> callStack; |
| 102 // Currently stack trace is only collected when inspector is open. | 102 // Currently stack trace is only collected when inspector is open. |
| 103 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) | 103 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) |
| 104 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt
ackSizeToCapture, isolate); | 104 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt
ackSizeToCapture, isolate); |
| 105 | 105 |
| 106 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); | 106 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); |
| 107 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin
g(); | 107 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin
g(); |
| 108 String resource = shouldUseDocumentURL ? firstWindow->document()->url() : to
WebCoreString(resourceName.As<v8::String>()); | 108 String resource = shouldUseDocumentURL ? firstWindow->document()->url() : to
CoreString(resourceName.As<v8::String>()); |
| 109 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; | 109 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; |
| 110 | 110 |
| 111 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, messag
e->GetLineNumber(), message->GetStartColumn() + 1, DOMWrapperWorld::current()); | 111 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, messag
e->GetLineNumber(), message->GetStartColumn() + 1, DOMWrapperWorld::current()); |
| 112 if (V8DOMWrapper::isDOMWrapper(data)) { | 112 if (V8DOMWrapper::isDOMWrapper(data)) { |
| 113 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data); | 113 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data); |
| 114 const WrapperTypeInfo* type = toWrapperTypeInfo(obj); | 114 const WrapperTypeInfo* type = toWrapperTypeInfo(obj); |
| 115 if (V8DOMException::wrapperTypeInfo.isSubclass(type)) { | 115 if (V8DOMException::wrapperTypeInfo.isSubclass(type)) { |
| 116 DOMException* exception = V8DOMException::toNative(obj); | 116 DOMException* exception = V8DOMException::toNative(obj); |
| 117 if (exception && !exception->messageForConsole().isEmpty()) | 117 if (exception && !exception->messageForConsole().isEmpty()) |
| 118 event->setUnsanitizedMessage("Uncaught " + exception->toStringFo
rConsole()); | 118 event->setUnsanitizedMessage("Uncaught " + exception->toStringFo
rConsole()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 { | 192 { |
| 193 static bool isReportingException = false; | 193 static bool isReportingException = false; |
| 194 // Exceptions that occur in error handler should be ignored since in that ca
se | 194 // Exceptions that occur in error handler should be ignored since in that ca
se |
| 195 // WorkerGlobalScope::reportException will send the exception to the worker
object. | 195 // WorkerGlobalScope::reportException will send the exception to the worker
object. |
| 196 if (isReportingException) | 196 if (isReportingException) |
| 197 return; | 197 return; |
| 198 isReportingException = true; | 198 isReportingException = true; |
| 199 | 199 |
| 200 // During the frame teardown, there may not be a valid context. | 200 // During the frame teardown, there may not be a valid context. |
| 201 if (ExecutionContext* context = getExecutionContext()) { | 201 if (ExecutionContext* context = getExecutionContext()) { |
| 202 String errorMessage = toWebCoreString(message->Get()); | 202 String errorMessage = toCoreString(message->Get()); |
| 203 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, sourceURL, mess
age->GetScriptResourceName()); | 203 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, sourceURL, mess
age->GetScriptResourceName()); |
| 204 | 204 |
| 205 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, m
essage->GetLineNumber(), message->GetStartColumn() + 1, DOMWrapperWorld::current
()); | 205 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, m
essage->GetLineNumber(), message->GetStartColumn() + 1, DOMWrapperWorld::current
()); |
| 206 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; | 206 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; |
| 207 | 207 |
| 208 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, v8:
:Isolate::GetCurrent()); | 208 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, v8:
:Isolate::GetCurrent()); |
| 209 context->reportException(event.release(), 0, corsStatus); | 209 context->reportException(event.release(), 0, corsStatus); |
| 210 } | 210 } |
| 211 | 211 |
| 212 isReportingException = false; | 212 isReportingException = false; |
| 213 } | 213 } |
| 214 | 214 |
| 215 static const int kWorkerMaxStackSize = 500 * 1024; | 215 static const int kWorkerMaxStackSize = 500 * 1024; |
| 216 | 216 |
| 217 void V8Initializer::initializeWorker(v8::Isolate* isolate) | 217 void V8Initializer::initializeWorker(v8::Isolate* isolate) |
| 218 { | 218 { |
| 219 initializeV8Common(isolate); | 219 initializeV8Common(isolate); |
| 220 | 220 |
| 221 v8::V8::AddMessageListener(messageHandlerInWorker); | 221 v8::V8::AddMessageListener(messageHandlerInWorker); |
| 222 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 222 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
| 223 | 223 |
| 224 v8::ResourceConstraints resourceConstraints; | 224 v8::ResourceConstraints resourceConstraints; |
| 225 uint32_t here; | 225 uint32_t here; |
| 226 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); | 226 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); |
| 227 v8::SetResourceConstraints(isolate, &resourceConstraints); | 227 v8::SetResourceConstraints(isolate, &resourceConstraints); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace WebCore | 230 } // namespace WebCore |
| OLD | NEW |