OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2012 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2012 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/dom/ExecutionContext.h" | 29 #include "core/dom/ExecutionContext.h" |
30 | 30 |
31 #include "core/dom/AddConsoleMessageTask.h" | 31 #include "core/dom/AddConsoleMessageTask.h" |
32 #include "core/dom/ContextLifecycleNotifier.h" | 32 #include "core/dom/ContextLifecycleNotifier.h" |
33 #include "core/dom/ExecutionContextTask.h" | 33 #include "core/dom/ExecutionContextTask.h" |
34 #include "core/events/ErrorEvent.h" | 34 #include "core/events/ErrorEvent.h" |
35 #include "core/events/EventTarget.h" | 35 #include "core/events/EventTarget.h" |
36 #include "core/html/PublicURLManager.h" | 36 #include "core/html/PublicURLManager.h" |
37 #include "core/inspector/InspectorInstrumentation.h" | 37 #include "core/inspector/InspectorInstrumentation.h" |
| 38 #include "core/inspector/ScriptArguments.h" |
38 #include "core/inspector/ScriptCallStack.h" | 39 #include "core/inspector/ScriptCallStack.h" |
39 #include "core/workers/WorkerGlobalScope.h" | 40 #include "core/workers/WorkerGlobalScope.h" |
40 #include "core/workers/WorkerThread.h" | 41 #include "core/workers/WorkerThread.h" |
41 #include "wtf/MainThread.h" | 42 #include "wtf/MainThread.h" |
42 | 43 |
43 namespace blink { | 44 namespace blink { |
44 | 45 |
45 class ExecutionContext::PendingException : public NoBaseWillBeGarbageCollectedFi
nalized<ExecutionContext::PendingException> { | 46 class ExecutionContext::PendingException : public NoBaseWillBeGarbageCollectedFi
nalized<ExecutionContext::PendingException> { |
46 WTF_MAKE_NONCOPYABLE(PendingException); | 47 WTF_MAKE_NONCOPYABLE(PendingException); |
47 public: | 48 public: |
48 PendingException(const String& errorMessage, int lineNumber, int columnNumbe
r, int scriptId, const String& sourceURL, PassRefPtrWillBeRawPtr<ScriptCallStack
> callStack) | 49 PendingException(const String& errorMessage, int lineNumber, int columnNumbe
r, int scriptId, const String& sourceURL, PassRefPtrWillBeRawPtr<ScriptCallStack
> callStack, PassRefPtrWillBeRawPtr<ScriptArguments> arguments) |
49 : m_errorMessage(errorMessage) | 50 : m_errorMessage(errorMessage) |
50 , m_lineNumber(lineNumber) | 51 , m_lineNumber(lineNumber) |
51 , m_columnNumber(columnNumber) | 52 , m_columnNumber(columnNumber) |
52 , m_scriptId(scriptId) | 53 , m_scriptId(scriptId) |
53 , m_sourceURL(sourceURL) | 54 , m_sourceURL(sourceURL) |
54 , m_callStack(callStack) | 55 , m_callStack(callStack) |
| 56 , m_arguments(arguments) |
55 { | 57 { |
56 } | 58 } |
57 void trace(Visitor* visitor) | 59 void trace(Visitor* visitor) |
58 { | 60 { |
59 visitor->trace(m_callStack); | 61 visitor->trace(m_callStack); |
| 62 visitor->trace(m_arguments); |
60 } | 63 } |
61 String m_errorMessage; | 64 String m_errorMessage; |
62 int m_lineNumber; | 65 int m_lineNumber; |
63 int m_columnNumber; | 66 int m_columnNumber; |
64 int m_scriptId; | 67 int m_scriptId; |
65 String m_sourceURL; | 68 String m_sourceURL; |
66 RefPtrWillBeMember<ScriptCallStack> m_callStack; | 69 RefPtrWillBeMember<ScriptCallStack> m_callStack; |
| 70 RefPtrWillBeMember<ScriptArguments> m_arguments; |
67 }; | 71 }; |
68 | 72 |
69 ExecutionContext::ExecutionContext() | 73 ExecutionContext::ExecutionContext() |
70 : m_sandboxFlags(SandboxNone) | 74 : m_sandboxFlags(SandboxNone) |
71 , m_circularSequentialID(0) | 75 , m_circularSequentialID(0) |
72 , m_inDispatchErrorEvent(false) | 76 , m_inDispatchErrorEvent(false) |
73 , m_activeDOMObjectsAreSuspended(false) | 77 , m_activeDOMObjectsAreSuspended(false) |
74 , m_activeDOMObjectsAreStopped(false) | 78 , m_activeDOMObjectsAreStopped(false) |
75 { | 79 { |
76 } | 80 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Ensure all ActiveDOMObjects are suspended also newly created ones. | 129 // Ensure all ActiveDOMObjects are suspended also newly created ones. |
126 if (m_activeDOMObjectsAreSuspended) | 130 if (m_activeDOMObjectsAreSuspended) |
127 object->suspend(); | 131 object->suspend(); |
128 } | 132 } |
129 | 133 |
130 bool ExecutionContext::shouldSanitizeScriptError(const String& sourceURL, Access
ControlStatus corsStatus) | 134 bool ExecutionContext::shouldSanitizeScriptError(const String& sourceURL, Access
ControlStatus corsStatus) |
131 { | 135 { |
132 return !(securityOrigin()->canRequest(completeURL(sourceURL)) || corsStatus
== SharableCrossOrigin); | 136 return !(securityOrigin()->canRequest(completeURL(sourceURL)) || corsStatus
== SharableCrossOrigin); |
133 } | 137 } |
134 | 138 |
135 void ExecutionContext::reportException(PassRefPtrWillBeRawPtr<ErrorEvent> event,
int scriptId, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack, AccessControlS
tatus corsStatus) | 139 void ExecutionContext::reportException(PassRefPtrWillBeRawPtr<ErrorEvent> event,
int scriptId, PassRefPtrWillBeRawPtr<ScriptCallStack> callStack, PassRefPtrWill
BeRawPtr<ScriptArguments> arguments, AccessControlStatus corsStatus, bool isProm
iseReject) |
136 { | 140 { |
137 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event; | 141 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event; |
138 if (m_inDispatchErrorEvent) { | 142 if (m_inDispatchErrorEvent) { |
139 if (!m_pendingExceptions) | 143 if (!m_pendingExceptions) |
140 m_pendingExceptions = adoptPtrWillBeNoop(new WillBeHeapVector<OwnPtr
WillBeMember<PendingException> >()); | 144 m_pendingExceptions = adoptPtrWillBeNoop(new WillBeHeapVector<OwnPtr
WillBeMember<PendingException> >()); |
141 m_pendingExceptions->append(adoptPtrWillBeNoop(new PendingException(erro
rEvent->messageForConsole(), errorEvent->lineno(), errorEvent->colno(), scriptId
, errorEvent->filename(), callStack))); | 145 m_pendingExceptions->append(adoptPtrWillBeNoop(new PendingException(erro
rEvent->messageForConsole(), errorEvent->lineno(), errorEvent->colno(), scriptId
, errorEvent->filename(), callStack, arguments))); |
142 return; | 146 return; |
143 } | 147 } |
144 | 148 |
145 // First report the original exception and only then all the nested ones. | 149 // First report the original exception and only then all the nested ones. |
146 if (!dispatchErrorEvent(errorEvent, corsStatus)) | 150 // FIXME: Do not dispatch uncaught Promise rejects until the window.onerror
spec is finalized. |
147 logExceptionToConsole(errorEvent->messageForConsole(), scriptId, errorEv
ent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack); | 151 if (isPromiseReject || !dispatchErrorEvent(errorEvent, corsStatus)) |
| 152 logExceptionToConsole(errorEvent->messageForConsole(), scriptId, errorEv
ent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack, arguments
); |
148 | 153 |
149 if (!m_pendingExceptions) | 154 if (!m_pendingExceptions) |
150 return; | 155 return; |
151 | 156 |
152 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { | 157 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { |
153 PendingException* e = m_pendingExceptions->at(i).get(); | 158 PendingException* e = m_pendingExceptions->at(i).get(); |
154 logExceptionToConsole(e->m_errorMessage, e->m_scriptId, e->m_sourceURL,
e->m_lineNumber, e->m_columnNumber, e->m_callStack); | 159 logExceptionToConsole(e->m_errorMessage, e->m_scriptId, e->m_sourceURL,
e->m_lineNumber, e->m_columnNumber, e->m_callStack, e->m_arguments); |
155 } | 160 } |
156 m_pendingExceptions.clear(); | 161 m_pendingExceptions.clear(); |
157 } | 162 } |
158 | 163 |
159 bool ExecutionContext::dispatchErrorEvent(PassRefPtrWillBeRawPtr<ErrorEvent> eve
nt, AccessControlStatus corsStatus) | 164 bool ExecutionContext::dispatchErrorEvent(PassRefPtrWillBeRawPtr<ErrorEvent> eve
nt, AccessControlStatus corsStatus) |
160 { | 165 { |
161 EventTarget* target = errorEventTarget(); | 166 EventTarget* target = errorEventTarget(); |
162 if (!target) | 167 if (!target) |
163 return false; | 168 return false; |
164 | 169 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 void ExecutionContext::trace(Visitor* visitor) | 272 void ExecutionContext::trace(Visitor* visitor) |
268 { | 273 { |
269 #if ENABLE(OILPAN) | 274 #if ENABLE(OILPAN) |
270 visitor->trace(m_pendingExceptions); | 275 visitor->trace(m_pendingExceptions); |
271 HeapSupplementable<ExecutionContext>::trace(visitor); | 276 HeapSupplementable<ExecutionContext>::trace(visitor); |
272 #endif | 277 #endif |
273 LifecycleContext<ExecutionContext>::trace(visitor); | 278 LifecycleContext<ExecutionContext>::trace(visitor); |
274 } | 279 } |
275 | 280 |
276 } // namespace blink | 281 } // namespace blink |
OLD | NEW |