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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 124 } |
124 } | 125 } |
125 | 126 |
126 // This method might be called while we're creating a new context. In this c
ase, we | 127 // 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. | 128 // 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? | 129 // 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(); | 130 LocalFrame* frame = enteredWindow->document()->frame(); |
130 if (frame && frame->script().existingWindowShell(scriptState->world())) { | 131 if (frame && frame->script().existingWindowShell(scriptState->world())) { |
131 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); | 132 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); |
132 } | 133 } |
133 enteredWindow->document()->reportException(event.release(), callStack, corsS
tatus); | 134 |
| 135 RefPtr<ConsoleMessage> consoleError = ConsoleMessage::create(JSMessageSource
, ErrorMessageLevel, event->messageForConsole(), resource, message->GetLineNumbe
r(), message->GetStartColumn() + 1, callStack, 0, corsStatus); |
| 136 enteredWindow->document()->reportException(event.release(), consoleError.rel
ease()); |
134 } | 137 } |
135 | 138 |
136 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) | 139 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) |
137 { | 140 { |
138 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 141 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
139 LocalFrame* target = findFrame(host, data, isolate); | 142 LocalFrame* target = findFrame(host, data, isolate); |
140 if (!target) | 143 if (!target) |
141 return; | 144 return; |
142 LocalDOMWindow* targetWindow = target->domWindow(); | 145 LocalDOMWindow* targetWindow = target->domWindow(); |
143 | 146 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 ScriptState* scriptState = ScriptState::current(isolate); | 223 ScriptState* scriptState = ScriptState::current(isolate); |
221 // During the frame teardown, there may not be a valid context. | 224 // During the frame teardown, there may not be a valid context. |
222 if (ExecutionContext* context = scriptState->executionContext()) { | 225 if (ExecutionContext* context = scriptState->executionContext()) { |
223 String errorMessage = toCoreString(message->Get()); | 226 String errorMessage = toCoreString(message->Get()); |
224 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin().
ResourceName()); | 227 TOSTRING_VOID(V8StringResource<>, sourceURL, message->GetScriptOrigin().
ResourceName()); |
225 | 228 |
226 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage,
sourceURL, message->GetLineNumber(), message->GetStartColumn() + 1, &DOMWrapperW
orld::current(isolate)); | 229 RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage,
sourceURL, message->GetLineNumber(), message->GetStartColumn() + 1, &DOMWrapperW
orld::current(isolate)); |
227 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; | 230 AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? Sharab
leCrossOrigin : NotSharableCrossOrigin; |
228 | 231 |
229 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); | 232 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); |
230 context->reportException(event.release(), nullptr, corsStatus); | 233 |
| 234 RefPtr<ConsoleMessage> consoleError = ConsoleMessage::create(JSMessageSo
urce, ErrorMessageLevel, errorMessage, sourceURL, message->GetLineNumber(), mess
age->GetStartColumn() + 1, nullptr, 0, corsStatus); |
| 235 context->reportException(event.release(), consoleError); |
231 } | 236 } |
232 | 237 |
233 isReportingException = false; | 238 isReportingException = false; |
234 } | 239 } |
235 | 240 |
236 static const int kWorkerMaxStackSize = 500 * 1024; | 241 static const int kWorkerMaxStackSize = 500 * 1024; |
237 | 242 |
238 void V8Initializer::initializeWorker(v8::Isolate* isolate) | 243 void V8Initializer::initializeWorker(v8::Isolate* isolate) |
239 { | 244 { |
240 initializeV8Common(isolate); | 245 initializeV8Common(isolate); |
241 | 246 |
242 v8::V8::AddMessageListener(messageHandlerInWorker); | 247 v8::V8::AddMessageListener(messageHandlerInWorker); |
243 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 248 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
244 | 249 |
245 v8::ResourceConstraints resourceConstraints; | 250 v8::ResourceConstraints resourceConstraints; |
246 uint32_t here; | 251 uint32_t here; |
247 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); | 252 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); |
248 v8::SetResourceConstraints(isolate, &resourceConstraints); | 253 v8::SetResourceConstraints(isolate, &resourceConstraints); |
249 } | 254 } |
250 | 255 |
251 } // namespace WebCore | 256 } // namespace WebCore |
OLD | NEW |