| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 RefPtr<ScriptCallStack> callStack; | 104 RefPtr<ScriptCallStack> callStack; |
| 105 // Currently stack trace is only collected when inspector is open. | 105 // Currently stack trace is only collected when inspector is open. |
| 106 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) | 106 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) |
| 107 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt
ackSizeToCapture, isolate); | 107 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt
ackSizeToCapture, isolate); |
| 108 | 108 |
| 109 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); | 109 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); |
| 110 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin
g(); | 110 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin
g(); |
| 111 String resource = shouldUseDocumentURL ? enteredWindow->document()->url() :
toCoreString(resourceName.As<v8::String>()); | 111 String resource = shouldUseDocumentURL ? enteredWindow->document()->url() :
toCoreString(resourceName.As<v8::String>()); |
| 112 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; | 112 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; |
| 113 | 113 |
| 114 DOMWrapperWorld* world = DOMWrapperWorld::current(isolate); | 114 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); |
| 115 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, messag
e->GetLineNumber(), message->GetStartColumn() + 1, world); | 115 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, messag
e->GetLineNumber(), message->GetStartColumn() + 1, &world); |
| 116 if (V8DOMWrapper::isDOMWrapper(data)) { | 116 if (V8DOMWrapper::isDOMWrapper(data)) { |
| 117 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data); | 117 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data); |
| 118 const WrapperTypeInfo* type = toWrapperTypeInfo(obj); | 118 const WrapperTypeInfo* type = toWrapperTypeInfo(obj); |
| 119 if (V8DOMException::wrapperTypeInfo.isSubclass(type)) { | 119 if (V8DOMException::wrapperTypeInfo.isSubclass(type)) { |
| 120 DOMException* exception = V8DOMException::toNative(obj); | 120 DOMException* exception = V8DOMException::toNative(obj); |
| 121 if (exception && !exception->messageForConsole().isEmpty()) | 121 if (exception && !exception->messageForConsole().isEmpty()) |
| 122 event->setUnsanitizedMessage("Uncaught " + exception->toStringFo
rConsole()); | 122 event->setUnsanitizedMessage("Uncaught " + exception->toStringFo
rConsole()); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 // This method might be called while we're creating a new context. In this c
ase, we | 126 // This method might be called while we're creating a new context. In this c
ase, we |
| 127 // avoid storing the exception object, as we can't create a wrapper during c
ontext creation. | 127 // avoid storing the exception object, as we can't create a wrapper during c
ontext creation. |
| 128 // FIXME: Can we even get here during initialization now that we bail out wh
en GetEntered returns an empty handle? | 128 // FIXME: Can we even get here during initialization now that we bail out wh
en GetEntered returns an empty handle? |
| 129 LocalFrame* frame = enteredWindow->document()->frame(); | 129 LocalFrame* frame = enteredWindow->document()->frame(); |
| 130 if (world && frame && frame->script().existingWindowShell(world)) | 130 if (frame && frame->script().existingWindowShell(world)) |
| 131 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, v8:
:Isolate::GetCurrent()); | 131 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, v8:
:Isolate::GetCurrent()); |
| 132 enteredWindow->document()->reportException(event.release(), callStack, corsS
tatus); | 132 enteredWindow->document()->reportException(event.release(), callStack, corsS
tatus); |
| 133 } | 133 } |
| 134 | 134 |
| 135 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) | 135 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) |
| 136 { | 136 { |
| 137 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 137 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 138 LocalFrame* target = findFrame(host, data, isolate); | 138 LocalFrame* target = findFrame(host, data, isolate); |
| 139 if (!target) | 139 if (!target) |
| 140 return; | 140 return; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 if (isReportingException) | 212 if (isReportingException) |
| 213 return; | 213 return; |
| 214 isReportingException = true; | 214 isReportingException = true; |
| 215 | 215 |
| 216 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 216 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 217 // During the frame teardown, there may not be a valid context. | 217 // During the frame teardown, there may not be a valid context. |
| 218 if (ExecutionContext* context = currentExecutionContext(isolate)) { | 218 if (ExecutionContext* context = currentExecutionContext(isolate)) { |
| 219 String errorMessage = toCoreString(message->Get()); | 219 String errorMessage = toCoreString(message->Get()); |
| 220 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, sourceURL, mess
age->GetScriptResourceName()); | 220 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, sourceURL, mess
age->GetScriptResourceName()); |
| 221 | 221 |
| 222 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, m
essage->GetLineNumber(), message->GetStartColumn() + 1, DOMWrapperWorld::current
(isolate)); | 222 RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, m
essage->GetLineNumber(), message->GetStartColumn() + 1, &DOMWrapperWorld::curren
t(isolate)); |
| 223 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; | 223 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; |
| 224 | 224 |
| 225 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, iso
late); | 225 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, iso
late); |
| 226 context->reportException(event.release(), nullptr, corsStatus); | 226 context->reportException(event.release(), nullptr, corsStatus); |
| 227 } | 227 } |
| 228 | 228 |
| 229 isReportingException = false; | 229 isReportingException = false; |
| 230 } | 230 } |
| 231 | 231 |
| 232 static const int kWorkerMaxStackSize = 500 * 1024; | 232 static const int kWorkerMaxStackSize = 500 * 1024; |
| 233 | 233 |
| 234 void V8Initializer::initializeWorker(v8::Isolate* isolate) | 234 void V8Initializer::initializeWorker(v8::Isolate* isolate) |
| 235 { | 235 { |
| 236 initializeV8Common(isolate); | 236 initializeV8Common(isolate); |
| 237 | 237 |
| 238 v8::V8::AddMessageListener(messageHandlerInWorker); | 238 v8::V8::AddMessageListener(messageHandlerInWorker); |
| 239 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 239 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
| 240 | 240 |
| 241 v8::ResourceConstraints resourceConstraints; | 241 v8::ResourceConstraints resourceConstraints; |
| 242 uint32_t here; | 242 uint32_t here; |
| 243 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); | 243 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); |
| 244 v8::SetResourceConstraints(isolate, &resourceConstraints); | 244 v8::SetResourceConstraints(isolate, &resourceConstraints); |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace WebCore | 247 } // namespace WebCore |
| OLD | NEW |