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 "bindings/core/v8/RejectedPromises.h" | 5 #include "bindings/core/v8/RejectedPromises.h" |
6 | 6 |
7 #include "bindings/core/v8/ScopedPersistent.h" | 7 #include "bindings/core/v8/ScopedPersistent.h" |
8 #include "bindings/core/v8/ScriptCallStack.h" | 8 #include "bindings/core/v8/ScriptCallStack.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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 return; | 63 return; |
64 ASSERT(!hasHandler()); | 64 ASSERT(!hasHandler()); |
65 | 65 |
66 EventTarget* target = executionContext->errorEventTarget(); | 66 EventTarget* target = executionContext->errorEventTarget(); |
67 if (RuntimeEnabledFeatures::promiseRejectionEventEnabled() && target &&
!executionContext->shouldSanitizeScriptError(m_resourceName, m_corsStatus)) { | 67 if (RuntimeEnabledFeatures::promiseRejectionEventEnabled() && target &&
!executionContext->shouldSanitizeScriptError(m_resourceName, m_corsStatus)) { |
68 PromiseRejectionEventInit init; | 68 PromiseRejectionEventInit init; |
69 init.setPromise(ScriptPromise(m_scriptState, value)); | 69 init.setPromise(ScriptPromise(m_scriptState, value)); |
70 init.setReason(ScriptValue(m_scriptState, reason)); | 70 init.setReason(ScriptValue(m_scriptState, reason)); |
71 init.setCancelable(true); | 71 init.setCancelable(true); |
72 RefPtrWillBeRawPtr<PromiseRejectionEvent> event = PromiseRejectionEv
ent::create(m_scriptState, EventTypeNames::unhandledrejection, init); | 72 RefPtrWillBeRawPtr<PromiseRejectionEvent> event = PromiseRejectionEv
ent::create(m_scriptState, EventTypeNames::unhandledrejection, init); |
73 // Log to console if event was not preventDefault()'ed. | 73 // Log to console if event was not canceled. |
74 m_shouldLogToConsole = target->dispatchEvent(event); | 74 m_shouldLogToConsole = target->dispatchEvent(event) == DispatchEvent
Result::NotCanceled; |
75 } | 75 } |
76 | 76 |
77 if (m_shouldLogToConsole) { | 77 if (m_shouldLogToConsole) { |
78 const String errorMessage = "Uncaught (in promise)"; | 78 const String errorMessage = "Uncaught (in promise)"; |
79 Vector<ScriptValue> args; | 79 Vector<ScriptValue> args; |
80 args.append(ScriptValue(m_scriptState, v8String(m_scriptState->isola
te(), errorMessage))); | 80 args.append(ScriptValue(m_scriptState, v8String(m_scriptState->isola
te(), errorMessage))); |
81 args.append(ScriptValue(m_scriptState, reason)); | 81 args.append(ScriptValue(m_scriptState, reason)); |
82 RefPtrWillBeRawPtr<ScriptArguments> arguments = ScriptArguments::cre
ate(m_scriptState, args); | 82 RefPtrWillBeRawPtr<ScriptArguments> arguments = ScriptArguments::cre
ate(m_scriptState, args); |
83 | 83 |
84 String embedderErrorMessage = m_errorMessage; | 84 String embedderErrorMessage = m_errorMessage; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 276 } |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 void RejectedPromises::revokeNow(PassOwnPtr<Message> message) | 280 void RejectedPromises::revokeNow(PassOwnPtr<Message> message) |
281 { | 281 { |
282 message->revoke(); | 282 message->revoke(); |
283 } | 283 } |
284 | 284 |
285 } // namespace blink | 285 } // namespace blink |
OLD | NEW |