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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if (!enteredWindow || !enteredWindow->isCurrentlyDisplayedInFrame()) | 105 if (!enteredWindow || !enteredWindow->isCurrentlyDisplayedInFrame()) |
106 return; | 106 return; |
107 | 107 |
108 String errorMessage = toCoreString(message->Get()); | 108 String errorMessage = toCoreString(message->Get()); |
109 | 109 |
110 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); | 110 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); |
111 RefPtrWillBeRawPtr<ScriptCallStack> callStack = nullptr; | 111 RefPtrWillBeRawPtr<ScriptCallStack> callStack = nullptr; |
112 int scriptId = message->GetScriptOrigin().ScriptID()->Value(); | 112 int scriptId = message->GetScriptOrigin().ScriptID()->Value(); |
113 // Currently stack trace is only collected when inspector is open. | 113 // Currently stack trace is only collected when inspector is open. |
114 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) { | 114 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) { |
115 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt
ackSizeToCapture, isolate); | 115 callStack = createScriptCallStack(isolate, stackTrace, ScriptCallStack::
maxCallStackSizeToCapture); |
116 bool success = false; | 116 bool success = false; |
117 int topScriptId = callStack->at(0).scriptId().toInt(&success); | 117 int topScriptId = callStack->at(0).scriptId().toInt(&success); |
118 if (success && topScriptId == scriptId) | 118 if (success && topScriptId == scriptId) |
119 scriptId = 0; | 119 scriptId = 0; |
120 } else { | 120 } else { |
121 Vector<ScriptCallFrame> callFrames; | 121 Vector<ScriptCallFrame> callFrames; |
122 callStack = ScriptCallStack::create(callFrames); | 122 callStack = ScriptCallStack::create(callFrames); |
123 } | 123 } |
124 | 124 |
125 v8::Handle<v8::Value> resourceName = message->GetScriptOrigin().ResourceName
(); | 125 v8::Handle<v8::Value> resourceName = message->GetScriptOrigin().ResourceName
(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return; | 249 return; |
250 v8::Handle<v8::Value> global = V8Window::findInstanceInPrototypeChain(contex
t->Global(), context->GetIsolate()); | 250 v8::Handle<v8::Value> global = V8Window::findInstanceInPrototypeChain(contex
t->Global(), context->GetIsolate()); |
251 if (global.IsEmpty()) | 251 if (global.IsEmpty()) |
252 return; | 252 return; |
253 if (!toFrameIfNotDetached(context)) | 253 if (!toFrameIfNotDetached(context)) |
254 return; | 254 return; |
255 | 255 |
256 RefPtrWillBeRawPtr<ScriptCallStack> callStack = nullptr; | 256 RefPtrWillBeRawPtr<ScriptCallStack> callStack = nullptr; |
257 v8::Handle<v8::StackTrace> stackTrace = message.GetStackTrace(); | 257 v8::Handle<v8::StackTrace> stackTrace = message.GetStackTrace(); |
258 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) | 258 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) |
259 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt
ackSizeToCapture, isolate); | 259 callStack = createScriptCallStack(isolate, stackTrace, ScriptCallStack::
maxCallStackSizeToCapture); |
260 | 260 |
261 if (!callStack && V8DOMWrapper::isDOMWrapper(message.GetValue())) { | 261 if (!callStack && V8DOMWrapper::isDOMWrapper(message.GetValue())) { |
262 // Try to get the stack from a wrapped exception object (e.g. DOMExcepti
on). | 262 // Try to get the stack from a wrapped exception object (e.g. DOMExcepti
on). |
263 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(message.GetVal
ue()); | 263 v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(message.GetVal
ue()); |
264 v8::Handle<v8::Value> error = V8HiddenValue::getHiddenValue(isolate, obj
, V8HiddenValue::error(isolate)); | 264 v8::Handle<v8::Value> error = V8HiddenValue::getHiddenValue(isolate, obj
, V8HiddenValue::error(isolate)); |
265 if (!error.IsEmpty()) { | 265 if (!error.IsEmpty()) { |
266 stackTrace = v8::Exception::GetStackTrace(error); | 266 stackTrace = v8::Exception::GetStackTrace(error); |
267 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) | 267 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) |
268 callStack = createScriptCallStack(stackTrace, ScriptCallStack::m
axCallStackSizeToCapture, isolate); | 268 callStack = createScriptCallStack(isolate, stackTrace, ScriptCal
lStack::maxCallStackSizeToCapture); |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 ScriptState* scriptState = ScriptState::from(context); | 272 ScriptState* scriptState = ScriptState::from(context); |
273 promiseRejectMessageQueue().append(PromiseRejectMessage(ScriptValue(scriptSt
ate, promise), callStack)); | 273 promiseRejectMessageQueue().append(PromiseRejectMessage(ScriptValue(scriptSt
ate, promise), callStack)); |
274 } | 274 } |
275 | 275 |
276 static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage message) | 276 static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage message) |
277 { | 277 { |
278 if (message.GetEvent() != v8::kPromiseRejectWithNoHandler) | 278 if (message.GetEvent() != v8::kPromiseRejectWithNoHandler) |
279 return; | 279 return; |
280 | 280 |
281 v8::Handle<v8::Promise> promise = message.GetPromise(); | 281 v8::Handle<v8::Promise> promise = message.GetPromise(); |
282 | 282 |
283 // Bail out if called during context initialization. | 283 // Bail out if called during context initialization. |
284 v8::Isolate* isolate = promise->GetIsolate(); | 284 v8::Isolate* isolate = promise->GetIsolate(); |
285 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); | 285 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); |
286 if (context.IsEmpty()) | 286 if (context.IsEmpty()) |
287 return; | 287 return; |
288 | 288 |
289 RefPtrWillBeRawPtr<ScriptCallStack> callStack = nullptr; | 289 RefPtrWillBeRawPtr<ScriptCallStack> callStack = nullptr; |
290 v8::Handle<v8::StackTrace> stackTrace = message.GetStackTrace(); | 290 v8::Handle<v8::StackTrace> stackTrace = message.GetStackTrace(); |
291 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) | 291 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) |
292 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt
ackSizeToCapture, isolate); | 292 callStack = createScriptCallStack(isolate, stackTrace, ScriptCallStack::
maxCallStackSizeToCapture); |
293 | 293 |
294 ScriptState* scriptState = ScriptState::from(context); | 294 ScriptState* scriptState = ScriptState::from(context); |
295 promiseRejectMessageQueue().append(PromiseRejectMessage(ScriptValue(scriptSt
ate, promise), callStack)); | 295 promiseRejectMessageQueue().append(PromiseRejectMessage(ScriptValue(scriptSt
ate, promise), callStack)); |
296 } | 296 } |
297 | 297 |
298 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) | 298 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) |
299 { | 299 { |
300 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 300 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
301 LocalFrame* target = findFrame(host, data, isolate); | 301 LocalFrame* target = findFrame(host, data, isolate); |
302 if (!target) | 302 if (!target) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 435 |
436 v8::V8::AddMessageListener(messageHandlerInWorker); | 436 v8::V8::AddMessageListener(messageHandlerInWorker); |
437 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 437 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
438 | 438 |
439 uint32_t here; | 439 uint32_t here; |
440 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); | 440 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); |
441 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 441 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
442 } | 442 } |
443 | 443 |
444 } // namespace blink | 444 } // namespace blink |
OLD | NEW |