| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "bindings/core/v8/RejectedPromises.h" | 6 #include "bindings/core/v8/RejectedPromises.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScopedPersistent.h" | 8 #include "bindings/core/v8/ScopedPersistent.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/ScriptValue.h" | 10 #include "bindings/core/v8/ScriptValue.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return; | 68 return; |
| 69 ASSERT(!hasHandler()); | 69 ASSERT(!hasHandler()); |
| 70 | 70 |
| 71 EventTarget* target = executionContext->errorEventTarget(); | 71 EventTarget* target = executionContext->errorEventTarget(); |
| 72 if (RuntimeEnabledFeatures::promiseRejectionEventEnabled() && target &&
!executionContext->shouldSanitizeScriptError(m_resourceName, m_corsStatus)) { | 72 if (RuntimeEnabledFeatures::promiseRejectionEventEnabled() && target &&
!executionContext->shouldSanitizeScriptError(m_resourceName, m_corsStatus)) { |
| 73 PromiseRejectionEventInit init; | 73 PromiseRejectionEventInit init; |
| 74 init.setPromise(ScriptPromise(m_scriptState, value)); | 74 init.setPromise(ScriptPromise(m_scriptState, value)); |
| 75 init.setReason(ScriptValue(m_scriptState, reason)); | 75 init.setReason(ScriptValue(m_scriptState, reason)); |
| 76 init.setCancelable(true); | 76 init.setCancelable(true); |
| 77 RefPtrWillBeRawPtr<PromiseRejectionEvent> event = PromiseRejectionEv
ent::create(m_scriptState, EventTypeNames::unhandledrejection, init); | 77 RefPtrWillBeRawPtr<PromiseRejectionEvent> event = PromiseRejectionEv
ent::create(m_scriptState, EventTypeNames::unhandledrejection, init); |
| 78 // Log to console if event was not preventDefault()'ed. | 78 // Log to console if event was not handled. |
| 79 m_shouldLogToConsole = target->dispatchEvent(event); | 79 m_shouldLogToConsole = target->dispatchEvent(event) == WebInputEvent
Result::NotHandled; |
| 80 } | 80 } |
| 81 | 81 |
| 82 if (m_shouldLogToConsole) { | 82 if (m_shouldLogToConsole) { |
| 83 const String errorMessage = "Uncaught (in promise)"; | 83 const String errorMessage = "Uncaught (in promise)"; |
| 84 Vector<ScriptValue> args; | 84 Vector<ScriptValue> args; |
| 85 args.append(ScriptValue(m_scriptState, v8String(m_scriptState->isola
te(), errorMessage))); | 85 args.append(ScriptValue(m_scriptState, v8String(m_scriptState->isola
te(), errorMessage))); |
| 86 args.append(ScriptValue(m_scriptState, reason)); | 86 args.append(ScriptValue(m_scriptState, reason)); |
| 87 RefPtrWillBeRawPtr<ScriptArguments> arguments = ScriptArguments::cre
ate(m_scriptState, args); | 87 RefPtrWillBeRawPtr<ScriptArguments> arguments = ScriptArguments::cre
ate(m_scriptState, args); |
| 88 | 88 |
| 89 String embedderErrorMessage = m_errorMessage; | 89 String embedderErrorMessage = m_errorMessage; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 void RejectedPromises::revokeNow(PassOwnPtrWillBeRawPtr<Message> message) | 288 void RejectedPromises::revokeNow(PassOwnPtrWillBeRawPtr<Message> message) |
| 289 { | 289 { |
| 290 message->revoke(); | 290 message->revoke(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 } // namespace blink | 293 } // namespace blink |
| OLD | NEW |