| 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 27 matching lines...) Expand all Loading... |
| 38 #include "bindings/core/v8/V8History.h" | 38 #include "bindings/core/v8/V8History.h" |
| 39 #include "bindings/core/v8/V8Location.h" | 39 #include "bindings/core/v8/V8Location.h" |
| 40 #include "bindings/core/v8/V8PerContextData.h" | 40 #include "bindings/core/v8/V8PerContextData.h" |
| 41 #include "bindings/core/v8/V8Window.h" | 41 #include "bindings/core/v8/V8Window.h" |
| 42 #include "core/dom/Document.h" | 42 #include "core/dom/Document.h" |
| 43 #include "core/dom/ExceptionCode.h" | 43 #include "core/dom/ExceptionCode.h" |
| 44 #include "core/frame/ConsoleTypes.h" | 44 #include "core/frame/ConsoleTypes.h" |
| 45 #include "core/frame/LocalDOMWindow.h" | 45 #include "core/frame/LocalDOMWindow.h" |
| 46 #include "core/frame/LocalFrame.h" | 46 #include "core/frame/LocalFrame.h" |
| 47 #include "core/frame/csp/ContentSecurityPolicy.h" | 47 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 48 #include "core/inspector/ConsoleMessage.h" |
| 48 #include "core/inspector/ScriptCallStack.h" | 49 #include "core/inspector/ScriptCallStack.h" |
| 49 #include "platform/TraceEvent.h" | 50 #include "platform/TraceEvent.h" |
| 50 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
| 51 #include "wtf/RefPtr.h" | 52 #include "wtf/RefPtr.h" |
| 52 #include "wtf/text/WTFString.h" | 53 #include "wtf/text/WTFString.h" |
| 53 #include <v8-debug.h> | 54 #include <v8-debug.h> |
| 54 | 55 |
| 55 namespace WebCore { | 56 namespace WebCore { |
| 56 | 57 |
| 57 static LocalFrame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> da
ta, v8::Isolate* isolate) | 58 static LocalFrame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> da
ta, v8::Isolate* isolate) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 String resource = shouldUseDocumentURL ? enteredWindow->document()->url() :
toCoreString(resourceName.As<v8::String>()); | 112 String resource = shouldUseDocumentURL ? enteredWindow->document()->url() :
toCoreString(resourceName.As<v8::String>()); |
| 112 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; | 113 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCr
ossOrigin : NotSharableCrossOrigin; |
| 113 | 114 |
| 114 ScriptState* scriptState = ScriptState::current(isolate); | 115 ScriptState* scriptState = ScriptState::current(isolate); |
| 115 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, reso
urce, message->GetLineNumber(), message->GetStartColumn() + 1, &scriptState->wor
ld()); | 116 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, reso
urce, message->GetLineNumber(), message->GetStartColumn() + 1, &scriptState->wor
ld()); |
| 116 if (V8DOMWrapper::isDOMWrapper(data)) { | 117 if (V8DOMWrapper::isDOMWrapper(data)) { |
| 117 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data); | 118 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data); |
| 118 const WrapperTypeInfo* type = toWrapperTypeInfo(obj); | 119 const WrapperTypeInfo* type = toWrapperTypeInfo(obj); |
| 119 if (V8DOMException::wrapperTypeInfo.isSubclass(type)) { | 120 if (V8DOMException::wrapperTypeInfo.isSubclass(type)) { |
| 120 DOMException* exception = V8DOMException::toNative(obj); | 121 DOMException* exception = V8DOMException::toNative(obj); |
| 121 if (exception && !exception->messageForConsole().isEmpty()) | 122 if (exception && !exception->messageForConsole().isEmpty()) { |
| 122 event->setUnsanitizedMessage("Uncaught " + exception->toStringFo
rConsole()); | 123 event->setUnsanitizedMessage("Uncaught " + exception->toStringFo
rConsole()); |
| 124 } |
| 123 } | 125 } |
| 124 } | 126 } |
| 125 | 127 |
| 126 // This method might be called while we're creating a new context. In this c
ase, we | 128 // 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. | 129 // 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? | 130 // 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(); | 131 LocalFrame* frame = enteredWindow->document()->frame(); |
| 130 if (frame && frame->script().existingWindowShell(scriptState->world())) { | 132 if (frame && frame->script().existingWindowShell(scriptState->world())) { |
| 131 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); | 133 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); |
| 132 } | 134 } |
| 133 enteredWindow->document()->reportException(event.release(), callStack, corsS
tatus); | 135 |
| 136 RefPtrWillBeRawPtr<ConsoleMessage> consoleError = ConsoleMessage::create(JSM
essageSource, ErrorMessageLevel, event->messageForConsole(), resource, message->
GetLineNumber(), message->GetStartColumn() + 1, callStack, scriptState, 0, corsS
tatus); |
| 137 enteredWindow->document()->reportException(event.release(), consoleError.rel
ease()); |
| 134 } | 138 } |
| 135 | 139 |
| 136 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) | 140 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) |
| 137 { | 141 { |
| 138 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 142 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 139 LocalFrame* target = findFrame(host, data, isolate); | 143 LocalFrame* target = findFrame(host, data, isolate); |
| 140 if (!target) | 144 if (!target) |
| 141 return; | 145 return; |
| 142 LocalDOMWindow* targetWindow = target->domWindow(); | 146 LocalDOMWindow* targetWindow = target->domWindow(); |
| 143 | 147 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 ScriptState* scriptState = ScriptState::current(isolate); | 224 ScriptState* scriptState = ScriptState::current(isolate); |
| 221 // During the frame teardown, there may not be a valid context. | 225 // During the frame teardown, there may not be a valid context. |
| 222 if (ExecutionContext* context = scriptState->executionContext()) { | 226 if (ExecutionContext* context = scriptState->executionContext()) { |
| 223 String errorMessage = toCoreString(message->Get()); | 227 String errorMessage = toCoreString(message->Get()); |
| 224 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin().
ResourceName()); | 228 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin().
ResourceName()); |
| 225 | 229 |
| 226 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage,
sourceURL, message->GetLineNumber(), message->GetStartColumn() + 1, &DOMWrapperW
orld::current(isolate)); | 230 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage,
sourceURL, message->GetLineNumber(), message->GetStartColumn() + 1, &DOMWrapperW
orld::current(isolate)); |
| 227 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; | 231 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; |
| 228 | 232 |
| 229 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); | 233 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); |
| 230 context->reportException(event.release(), nullptr, corsStatus); | 234 |
| 235 RefPtrWillBeRawPtr<ConsoleMessage> consoleError = ConsoleMessage::create
(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, message->GetLineNu
mber(), message->GetStartColumn() + 1, nullptr, scriptState, 0, corsStatus); |
| 236 context->reportException(event.release(), consoleError); |
| 231 } | 237 } |
| 232 | 238 |
| 233 isReportingException = false; | 239 isReportingException = false; |
| 234 } | 240 } |
| 235 | 241 |
| 236 static const int kWorkerMaxStackSize = 500 * 1024; | 242 static const int kWorkerMaxStackSize = 500 * 1024; |
| 237 | 243 |
| 238 void V8Initializer::initializeWorker(v8::Isolate* isolate) | 244 void V8Initializer::initializeWorker(v8::Isolate* isolate) |
| 239 { | 245 { |
| 240 initializeV8Common(isolate); | 246 initializeV8Common(isolate); |
| 241 | 247 |
| 242 v8::V8::AddMessageListener(messageHandlerInWorker); | 248 v8::V8::AddMessageListener(messageHandlerInWorker); |
| 243 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 249 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
| 244 | 250 |
| 245 v8::ResourceConstraints resourceConstraints; | 251 v8::ResourceConstraints resourceConstraints; |
| 246 uint32_t here; | 252 uint32_t here; |
| 247 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); | 253 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); |
| 248 v8::SetResourceConstraints(isolate, &resourceConstraints); | 254 v8::SetResourceConstraints(isolate, &resourceConstraints); |
| 249 } | 255 } |
| 250 | 256 |
| 251 } // namespace WebCore | 257 } // namespace WebCore |
| OLD | NEW |