| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 object->suspend(); | 140 object->suspend(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool ExecutionContext::shouldSanitizeScriptError(const String& sourceURL, Access
ControlStatus corsStatus) | 143 bool ExecutionContext::shouldSanitizeScriptError(const String& sourceURL, Access
ControlStatus corsStatus) |
| 144 { | 144 { |
| 145 if (corsStatus == OpaqueResource) | 145 if (corsStatus == OpaqueResource) |
| 146 return true; | 146 return true; |
| 147 return !(securityOrigin()->canRequestNoSuborigin(completeURL(sourceURL)) ||
corsStatus == SharableCrossOrigin); | 147 return !(securityOrigin()->canRequestNoSuborigin(completeURL(sourceURL)) ||
corsStatus == SharableCrossOrigin); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void ExecutionContext::reportException(PassRefPtrWillBeRawPtr<ErrorEvent> event,
int scriptId, PassRefPtr<ScriptCallStack> callStack, AccessControlStatus corsSt
atus) | 150 void ExecutionContext::reportException(RawPtr<ErrorEvent> event, int scriptId, P
assRefPtr<ScriptCallStack> callStack, AccessControlStatus corsStatus) |
| 151 { | 151 { |
| 152 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event; | 152 RawPtr<ErrorEvent> errorEvent = event; |
| 153 if (m_inDispatchErrorEvent) { | 153 if (m_inDispatchErrorEvent) { |
| 154 if (!m_pendingExceptions) | 154 if (!m_pendingExceptions) |
| 155 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException>>(
)); | 155 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException>>(
)); |
| 156 m_pendingExceptions->append(adoptPtr(new PendingException(errorEvent->me
ssageForConsole(), errorEvent->lineno(), errorEvent->colno(), scriptId, errorEve
nt->filename(), callStack))); | 156 m_pendingExceptions->append(adoptPtr(new PendingException(errorEvent->me
ssageForConsole(), errorEvent->lineno(), errorEvent->colno(), scriptId, errorEve
nt->filename(), callStack))); |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 | 159 |
| 160 // First report the original exception and only then all the nested ones. | 160 // First report the original exception and only then all the nested ones. |
| 161 if (!dispatchErrorEvent(errorEvent, corsStatus)) | 161 if (!dispatchErrorEvent(errorEvent, corsStatus)) |
| 162 logExceptionToConsole(errorEvent->messageForConsole(), scriptId, errorEv
ent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack); | 162 logExceptionToConsole(errorEvent->messageForConsole(), scriptId, errorEv
ent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack); |
| 163 | 163 |
| 164 if (!m_pendingExceptions) | 164 if (!m_pendingExceptions) |
| 165 return; | 165 return; |
| 166 | 166 |
| 167 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { | 167 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { |
| 168 PendingException* e = m_pendingExceptions->at(i).get(); | 168 PendingException* e = m_pendingExceptions->at(i).get(); |
| 169 logExceptionToConsole(e->m_errorMessage, e->m_scriptId, e->m_sourceURL,
e->m_lineNumber, e->m_columnNumber, e->m_callStack); | 169 logExceptionToConsole(e->m_errorMessage, e->m_scriptId, e->m_sourceURL,
e->m_lineNumber, e->m_columnNumber, e->m_callStack); |
| 170 } | 170 } |
| 171 m_pendingExceptions.clear(); | 171 m_pendingExceptions.clear(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool ExecutionContext::dispatchErrorEvent(PassRefPtrWillBeRawPtr<ErrorEvent> eve
nt, AccessControlStatus corsStatus) | 174 bool ExecutionContext::dispatchErrorEvent(RawPtr<ErrorEvent> event, AccessContro
lStatus corsStatus) |
| 175 { | 175 { |
| 176 EventTarget* target = errorEventTarget(); | 176 EventTarget* target = errorEventTarget(); |
| 177 if (!target) | 177 if (!target) |
| 178 return false; | 178 return false; |
| 179 | 179 |
| 180 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event; | 180 RawPtr<ErrorEvent> errorEvent = event; |
| 181 if (shouldSanitizeScriptError(errorEvent->filename(), corsStatus)) | 181 if (shouldSanitizeScriptError(errorEvent->filename(), corsStatus)) |
| 182 errorEvent = ErrorEvent::createSanitizedError(errorEvent->world()); | 182 errorEvent = ErrorEvent::createSanitizedError(errorEvent->world()); |
| 183 | 183 |
| 184 ASSERT(!m_inDispatchErrorEvent); | 184 ASSERT(!m_inDispatchErrorEvent); |
| 185 m_inDispatchErrorEvent = true; | 185 m_inDispatchErrorEvent = true; |
| 186 target->dispatchEvent(errorEvent); | 186 target->dispatchEvent(errorEvent); |
| 187 m_inDispatchErrorEvent = false; | 187 m_inDispatchErrorEvent = false; |
| 188 return errorEvent->defaultPrevented(); | 188 return errorEvent->defaultPrevented(); |
| 189 } | 189 } |
| 190 | 190 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 DEFINE_TRACE(ExecutionContext) | 298 DEFINE_TRACE(ExecutionContext) |
| 299 { | 299 { |
| 300 #if ENABLE(OILPAN) | 300 #if ENABLE(OILPAN) |
| 301 visitor->trace(m_publicURLManager); | 301 visitor->trace(m_publicURLManager); |
| 302 HeapSupplementable<ExecutionContext>::trace(visitor); | 302 HeapSupplementable<ExecutionContext>::trace(visitor); |
| 303 #endif | 303 #endif |
| 304 ContextLifecycleNotifier::trace(visitor); | 304 ContextLifecycleNotifier::trace(visitor); |
| 305 } | 305 } |
| 306 | 306 |
| 307 } // namespace blink | 307 } // namespace blink |
| OLD | NEW |