Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: Source/bindings/core/v8/V8Initializer.cpp

Issue 1095943002: DevTools: [console] Logged promise rejections do not change state once handled (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: for landing Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/core/v8/RejectedPromises.cpp ('k') | Source/core/frame/ConsoleTypes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } // namespace 196 } // namespace
197 197
198 void V8Initializer::reportRejectedPromisesOnMainThread() 198 void V8Initializer::reportRejectedPromisesOnMainThread()
199 { 199 {
200 rejectedPromisesOnMainThread().processQueue(); 200 rejectedPromisesOnMainThread().processQueue();
201 } 201 }
202 202
203 static void promiseRejectHandlerInMainThread(v8::PromiseRejectMessage data) 203 static void promiseRejectHandlerInMainThread(v8::PromiseRejectMessage data)
204 { 204 {
205 ASSERT(isMainThread()); 205 ASSERT(isMainThread());
206 if (data.GetEvent() != v8::kPromiseRejectWithNoHandler) 206 if (data.GetEvent() == v8::kPromiseHandlerAddedAfterReject) {
207 rejectedPromisesOnMainThread().handlerAdded(data);
207 return; 208 return;
209 }
210
211 ASSERT(data.GetEvent() == v8::kPromiseRejectWithNoHandler);
212
208 v8::Handle<v8::Promise> promise = data.GetPromise(); 213 v8::Handle<v8::Promise> promise = data.GetPromise();
209 214
210 v8::Isolate* isolate = promise->GetIsolate(); 215 v8::Isolate* isolate = promise->GetIsolate();
211 // There is no entered window during microtask callbacks from V8, 216 // There is no entered window during microtask callbacks from V8,
212 // thus we call toDOMWindow() instead of enteredDOMWindow(). 217 // thus we call toDOMWindow() instead of enteredDOMWindow().
213 LocalDOMWindow* window = currentDOMWindow(isolate); 218 LocalDOMWindow* window = currentDOMWindow(isolate);
214 if (!window || !window->isCurrentlyDisplayedInFrame()) 219 if (!window || !window->isCurrentlyDisplayedInFrame())
215 return; 220 return;
216 221
217 v8::Handle<v8::Value> exception = data.GetValue(); 222 v8::Handle<v8::Value> exception = data.GetValue();
(...skipping 24 matching lines...) Expand all
242 } else if (!exception.IsEmpty() && exception->IsInt32()) { 247 } else if (!exception.IsEmpty() && exception->IsInt32()) {
243 // For Smi's the message would be empty. 248 // For Smi's the message would be empty.
244 errorMessage = "Uncaught " + String::number(exception.As<v8::Integer>()- >Value()); 249 errorMessage = "Uncaught " + String::number(exception.As<v8::Integer>()- >Value());
245 } 250 }
246 251
247 String messageForConsole = extractMessageForConsole(isolate, data.GetValue() ); 252 String messageForConsole = extractMessageForConsole(isolate, data.GetValue() );
248 if (!messageForConsole.isEmpty()) 253 if (!messageForConsole.isEmpty())
249 errorMessage = "Uncaught " + messageForConsole; 254 errorMessage = "Uncaught " + messageForConsole;
250 255
251 ScriptState* scriptState = ScriptState::current(isolate); 256 ScriptState* scriptState = ScriptState::current(isolate);
252 rejectedPromisesOnMainThread().add(scriptState, data, errorMessage, resource Name, scriptId, lineNumber, columnNumber, callStack); 257 rejectedPromisesOnMainThread().rejectedWithNoHandler(scriptState, data, erro rMessage, resourceName, scriptId, lineNumber, columnNumber, callStack);
253 } 258 }
254 259
255 static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage data) 260 static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage data)
256 { 261 {
257 if (data.GetEvent() != v8::kPromiseRejectWithNoHandler)
258 return;
259
260 v8::Handle<v8::Promise> promise = data.GetPromise(); 262 v8::Handle<v8::Promise> promise = data.GetPromise();
261 263
262 // Bail out if called during context initialization. 264 // Bail out if called during context initialization.
263 v8::Isolate* isolate = promise->GetIsolate(); 265 v8::Isolate* isolate = promise->GetIsolate();
264 ScriptState* scriptState = ScriptState::current(isolate); 266 ScriptState* scriptState = ScriptState::current(isolate);
265 if (!scriptState->contextIsValid()) 267 if (!scriptState->contextIsValid())
266 return; 268 return;
267 269
268 ExecutionContext* executionContext = scriptState->executionContext(); 270 ExecutionContext* executionContext = scriptState->executionContext();
269 if (!executionContext) 271 if (!executionContext)
270 return; 272 return;
271 273
272 ASSERT(executionContext->isWorkerGlobalScope()); 274 ASSERT(executionContext->isWorkerGlobalScope());
273 WorkerScriptController* scriptController = toWorkerGlobalScope(executionCont ext)->script(); 275 WorkerScriptController* scriptController = toWorkerGlobalScope(executionCont ext)->script();
274 ASSERT(scriptController); 276 ASSERT(scriptController);
275 277
278 if (data.GetEvent() == v8::kPromiseHandlerAddedAfterReject) {
279 scriptController->rejectedPromises()->handlerAdded(data);
280 return;
281 }
282
283 ASSERT(data.GetEvent() == v8::kPromiseRejectWithNoHandler);
284
276 int scriptId = 0; 285 int scriptId = 0;
277 int lineNumber = 0; 286 int lineNumber = 0;
278 int columnNumber = 0; 287 int columnNumber = 0;
279 String resourceName; 288 String resourceName;
280 String errorMessage; 289 String errorMessage;
281 290
282 v8::Handle<v8::Message> message = v8::Exception::CreateMessage(data.GetValue ()); 291 v8::Handle<v8::Message> message = v8::Exception::CreateMessage(data.GetValue ());
283 if (!message.IsEmpty()) { 292 if (!message.IsEmpty()) {
284 TOSTRING_VOID(V8StringResource<>, resourceName, message->GetScriptOrigin ().ResourceName()); 293 TOSTRING_VOID(V8StringResource<>, resourceName, message->GetScriptOrigin ().ResourceName());
285 scriptId = message->GetScriptOrigin().ScriptID()->Value(); 294 scriptId = message->GetScriptOrigin().ScriptID()->Value();
286 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber) 295 if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber)
287 && v8Call(message->GetStartColumn(scriptState->context()), columnNum ber)) 296 && v8Call(message->GetStartColumn(scriptState->context()), columnNum ber))
288 ++columnNumber; 297 ++columnNumber;
289 // message->Get() can be empty here. https://crbug.com/450330 298 // message->Get() can be empty here. https://crbug.com/450330
290 errorMessage = toCoreStringWithNullCheck(message->Get()); 299 errorMessage = toCoreStringWithNullCheck(message->Get());
291 } 300 }
292 scriptController->rejectedPromises()->add(scriptState, data, errorMessage, r esourceName, scriptId, lineNumber, columnNumber, nullptr); 301 scriptController->rejectedPromises()->rejectedWithNoHandler(scriptState, dat a, errorMessage, resourceName, scriptId, lineNumber, columnNumber, nullptr);
293 } 302 }
294 303
295 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8 ::AccessType type, v8::Local<v8::Value> data) 304 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8 ::AccessType type, v8::Local<v8::Value> data)
296 { 305 {
297 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 306 v8::Isolate* isolate = v8::Isolate::GetCurrent();
298 Frame* target = findFrame(host, data, isolate); 307 Frame* target = findFrame(host, data, isolate);
299 if (!target) 308 if (!target)
300 return; 309 return;
301 DOMWindow* targetWindow = target->domWindow(); 310 DOMWindow* targetWindow = target->domWindow();
302 311
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 470
462 v8::V8::AddMessageListener(messageHandlerInWorker); 471 v8::V8::AddMessageListener(messageHandlerInWorker);
463 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); 472 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker);
464 473
465 uint32_t here; 474 uint32_t here;
466 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*))); 475 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi ze / sizeof(uint32_t*)));
467 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); 476 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker);
468 } 477 }
469 478
470 } // namespace blink 479 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/RejectedPromises.cpp ('k') | Source/core/frame/ConsoleTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698