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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Ensure all ActiveDOMObjects are suspended also newly created ones. | 121 // Ensure all ActiveDOMObjects are suspended also newly created ones. |
122 if (m_activeDOMObjectsAreSuspended) | 122 if (m_activeDOMObjectsAreSuspended) |
123 object->suspend(); | 123 object->suspend(); |
124 } | 124 } |
125 | 125 |
126 bool ExecutionContext::shouldSanitizeScriptError(const String& sourceURL, Access
ControlStatus corsStatus) | 126 bool ExecutionContext::shouldSanitizeScriptError(const String& sourceURL, Access
ControlStatus corsStatus) |
127 { | 127 { |
128 return !(securityOrigin()->canRequest(completeURL(sourceURL)) || corsStatus
== SharableCrossOrigin); | 128 return !(securityOrigin()->canRequest(completeURL(sourceURL)) || corsStatus
== SharableCrossOrigin); |
129 } | 129 } |
130 | 130 |
131 void ExecutionContext::reportException(PassRefPtr<ErrorEvent> event, PassRefPtr<
ScriptCallStack> callStack, AccessControlStatus corsStatus) | 131 void ExecutionContext::reportException(PassRefPtrWillBeRawPtr<ErrorEvent> event,
PassRefPtr<ScriptCallStack> callStack, AccessControlStatus corsStatus) |
132 { | 132 { |
133 RefPtr<ErrorEvent> errorEvent = event; | 133 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event; |
134 if (m_inDispatchErrorEvent) { | 134 if (m_inDispatchErrorEvent) { |
135 if (!m_pendingExceptions) | 135 if (!m_pendingExceptions) |
136 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> >
()); | 136 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> >
()); |
137 m_pendingExceptions->append(adoptPtr(new PendingException(errorEvent->me
ssageForConsole(), errorEvent->lineno(), errorEvent->colno(), errorEvent->filena
me(), callStack))); | 137 m_pendingExceptions->append(adoptPtr(new PendingException(errorEvent->me
ssageForConsole(), errorEvent->lineno(), errorEvent->colno(), errorEvent->filena
me(), callStack))); |
138 return; | 138 return; |
139 } | 139 } |
140 | 140 |
141 // First report the original exception and only then all the nested ones. | 141 // First report the original exception and only then all the nested ones. |
142 if (!dispatchErrorEvent(errorEvent, corsStatus) && m_client) | 142 if (!dispatchErrorEvent(errorEvent, corsStatus) && m_client) |
143 m_client->logExceptionToConsole(errorEvent->messageForConsole(), errorEv
ent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack); | 143 m_client->logExceptionToConsole(errorEvent->messageForConsole(), errorEv
ent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack); |
(...skipping 16 matching lines...) Expand all Loading... |
160 m_client->addMessage(source, level, message, sourceURL, lineNumber, 0); | 160 m_client->addMessage(source, level, message, sourceURL, lineNumber, 0); |
161 } | 161 } |
162 | 162 |
163 void ExecutionContext::addConsoleMessage(MessageSource source, MessageLevel leve
l, const String& message, ScriptState* state) | 163 void ExecutionContext::addConsoleMessage(MessageSource source, MessageLevel leve
l, const String& message, ScriptState* state) |
164 { | 164 { |
165 if (!m_client) | 165 if (!m_client) |
166 return; | 166 return; |
167 m_client->addMessage(source, level, message, String(), 0, state); | 167 m_client->addMessage(source, level, message, String(), 0, state); |
168 } | 168 } |
169 | 169 |
170 bool ExecutionContext::dispatchErrorEvent(PassRefPtr<ErrorEvent> event, AccessCo
ntrolStatus corsStatus) | 170 bool ExecutionContext::dispatchErrorEvent(PassRefPtrWillBeRawPtr<ErrorEvent> eve
nt, AccessControlStatus corsStatus) |
171 { | 171 { |
172 if (!m_client) | 172 if (!m_client) |
173 return false; | 173 return false; |
174 EventTarget* target = m_client->errorEventTarget(); | 174 EventTarget* target = m_client->errorEventTarget(); |
175 if (!target) | 175 if (!target) |
176 return false; | 176 return false; |
177 | 177 |
178 RefPtr<ErrorEvent> errorEvent = event; | 178 RefPtrWillBeRawPtr<ErrorEvent> errorEvent = event; |
179 if (shouldSanitizeScriptError(errorEvent->filename(), corsStatus)) | 179 if (shouldSanitizeScriptError(errorEvent->filename(), corsStatus)) |
180 errorEvent = ErrorEvent::createSanitizedError(errorEvent->world()); | 180 errorEvent = ErrorEvent::createSanitizedError(errorEvent->world()); |
181 | 181 |
182 ASSERT(!m_inDispatchErrorEvent); | 182 ASSERT(!m_inDispatchErrorEvent); |
183 m_inDispatchErrorEvent = true; | 183 m_inDispatchErrorEvent = true; |
184 target->dispatchEvent(errorEvent); | 184 target->dispatchEvent(errorEvent); |
185 m_inDispatchErrorEvent = false; | 185 m_inDispatchErrorEvent = false; |
186 return errorEvent->defaultPrevented(); | 186 return errorEvent->defaultPrevented(); |
187 } | 187 } |
188 | 188 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 333 |
334 RELEASE_ASSERT(m_client); | 334 RELEASE_ASSERT(m_client); |
335 // The SandboxOrigin is stored redundantly in the security origin. | 335 // The SandboxOrigin is stored redundantly in the security origin. |
336 if (isSandboxed(SandboxOrigin) && m_client->securityContext().securityOrigin
() && !m_client->securityContext().securityOrigin()->isUnique()) { | 336 if (isSandboxed(SandboxOrigin) && m_client->securityContext().securityOrigin
() && !m_client->securityContext().securityOrigin()->isUnique()) { |
337 m_client->securityContext().setSecurityOrigin(SecurityOrigin::createUniq
ue()); | 337 m_client->securityContext().setSecurityOrigin(SecurityOrigin::createUniq
ue()); |
338 m_client->didUpdateSecurityOrigin(); | 338 m_client->didUpdateSecurityOrigin(); |
339 } | 339 } |
340 } | 340 } |
341 | 341 |
342 } // namespace WebCore | 342 } // namespace WebCore |
OLD | NEW |