| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 virtual void performTask(ScriptExecutionContext* context) | 54 virtual void performTask(ScriptExecutionContext* context) |
| 55 { | 55 { |
| 56 context->dispatchMessagePortEvents(); | 56 context->dispatchMessagePortEvents(); |
| 57 } | 57 } |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 class ScriptExecutionContext::PendingException { | 60 class ScriptExecutionContext::PendingException { |
| 61 WTF_MAKE_NONCOPYABLE(PendingException); | 61 WTF_MAKE_NONCOPYABLE(PendingException); |
| 62 public: | 62 public: |
| 63 PendingException(const String& errorMessage, int lineNumber, const String& s
ourceURL, PassRefPtr<ScriptCallStack> callStack) | 63 PendingException(const String& errorMessage, int lineNumber, int columnNumbe
r, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack) |
| 64 : m_errorMessage(errorMessage) | 64 : m_errorMessage(errorMessage) |
| 65 , m_lineNumber(lineNumber) | 65 , m_lineNumber(lineNumber) |
| 66 , m_columnNumber(columnNumber) |
| 66 , m_sourceURL(sourceURL) | 67 , m_sourceURL(sourceURL) |
| 67 , m_callStack(callStack) | 68 , m_callStack(callStack) |
| 68 { | 69 { |
| 69 } | 70 } |
| 70 String m_errorMessage; | 71 String m_errorMessage; |
| 71 int m_lineNumber; | 72 int m_lineNumber; |
| 73 int m_columnNumber; |
| 72 String m_sourceURL; | 74 String m_sourceURL; |
| 73 RefPtr<ScriptCallStack> m_callStack; | 75 RefPtr<ScriptCallStack> m_callStack; |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 void ScriptExecutionContext::AddConsoleMessageTask::performTask(ScriptExecutionC
ontext* context) | 78 void ScriptExecutionContext::AddConsoleMessageTask::performTask(ScriptExecutionC
ontext* context) |
| 77 { | 79 { |
| 78 context->addConsoleMessage(m_source, m_level, m_message); | 80 context->addConsoleMessage(m_source, m_level, m_message); |
| 79 } | 81 } |
| 80 | 82 |
| 81 ScriptExecutionContext::ScriptExecutionContext() | 83 ScriptExecutionContext::ScriptExecutionContext() |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 188 } |
| 187 | 189 |
| 188 void ScriptExecutionContext::closeMessagePorts() { | 190 void ScriptExecutionContext::closeMessagePorts() { |
| 189 HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end(); | 191 HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end(); |
| 190 for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter !=
messagePortsEnd; ++iter) { | 192 for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter !=
messagePortsEnd; ++iter) { |
| 191 ASSERT((*iter)->scriptExecutionContext() == this); | 193 ASSERT((*iter)->scriptExecutionContext() == this); |
| 192 (*iter)->close(); | 194 (*iter)->close(); |
| 193 } | 195 } |
| 194 } | 196 } |
| 195 | 197 |
| 196 bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& line
Number, String& sourceURL, CachedScript* cachedScript) | 198 bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& line
Number, int& columnNumber, String& sourceURL, CachedScript* cachedScript) |
| 197 { | 199 { |
| 198 KURL targetURL = completeURL(sourceURL); | 200 KURL targetURL = completeURL(sourceURL); |
| 199 if (securityOrigin()->canRequest(targetURL) || (cachedScript && cachedScript
->passesAccessControlCheck(securityOrigin()))) | 201 if (securityOrigin()->canRequest(targetURL) || (cachedScript && cachedScript
->passesAccessControlCheck(securityOrigin()))) |
| 200 return false; | 202 return false; |
| 201 errorMessage = "Script error."; | 203 errorMessage = "Script error."; |
| 202 sourceURL = String(); | 204 sourceURL = String(); |
| 203 lineNumber = 0; | 205 lineNumber = 0; |
| 206 columnNumber = 0; |
| 204 return true; | 207 return true; |
| 205 } | 208 } |
| 206 | 209 |
| 207 void ScriptExecutionContext::reportException(const String& errorMessage, int lin
eNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack, CachedS
cript* cachedScript) | 210 void ScriptExecutionContext::reportException(const String& errorMessage, int lin
eNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>
callStack, CachedScript* cachedScript) |
| 208 { | 211 { |
| 209 if (m_inDispatchErrorEvent) { | 212 if (m_inDispatchErrorEvent) { |
| 210 if (!m_pendingExceptions) | 213 if (!m_pendingExceptions) |
| 211 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> >
()); | 214 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> >
()); |
| 212 m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage,
lineNumber, sourceURL, callStack))); | 215 m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage,
lineNumber, columnNumber, sourceURL, callStack))); |
| 213 return; | 216 return; |
| 214 } | 217 } |
| 215 | 218 |
| 216 // First report the original exception and only then all the nested ones. | 219 // First report the original exception and only then all the nested ones. |
| 217 if (!dispatchErrorEvent(errorMessage, lineNumber, sourceURL, cachedScript)) | 220 if (!dispatchErrorEvent(errorMessage, lineNumber, columnNumber, sourceURL, c
achedScript)) |
| 218 logExceptionToConsole(errorMessage, sourceURL, lineNumber, callStack); | 221 logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber,
callStack); |
| 219 | 222 |
| 220 if (!m_pendingExceptions) | 223 if (!m_pendingExceptions) |
| 221 return; | 224 return; |
| 222 | 225 |
| 223 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { | 226 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { |
| 224 PendingException* e = m_pendingExceptions->at(i).get(); | 227 PendingException* e = m_pendingExceptions->at(i).get(); |
| 225 logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber
, e->m_callStack); | 228 logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber
, e->m_columnNumber, e->m_callStack); |
| 226 } | 229 } |
| 227 m_pendingExceptions.clear(); | 230 m_pendingExceptions.clear(); |
| 228 } | 231 } |
| 229 | 232 |
| 230 void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLeve
l level, const String& message, const String& sourceURL, unsigned lineNumber, Sc
riptState* state, unsigned long requestIdentifier) | 233 void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLeve
l level, const String& message, const String& sourceURL, unsigned lineNumber, Sc
riptState* state, unsigned long requestIdentifier) |
| 231 { | 234 { |
| 232 addMessage(source, level, message, sourceURL, lineNumber, 0, state, requestI
dentifier); | 235 addMessage(source, level, message, sourceURL, lineNumber, 0, state, requestI
dentifier); |
| 233 } | 236 } |
| 234 | 237 |
| 235 bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int
lineNumber, const String& sourceURL, CachedScript* cachedScript) | 238 bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int
lineNumber, int columnNumber, const String& sourceURL, CachedScript* cachedScrip
t) |
| 236 { | 239 { |
| 237 EventTarget* target = errorEventTarget(); | 240 EventTarget* target = errorEventTarget(); |
| 238 if (!target) | 241 if (!target) |
| 239 return false; | 242 return false; |
| 240 | 243 |
| 241 String message = errorMessage; | 244 String message = errorMessage; |
| 242 int line = lineNumber; | 245 int line = lineNumber; |
| 246 int column = columnNumber; |
| 243 String sourceName = sourceURL; | 247 String sourceName = sourceURL; |
| 244 sanitizeScriptError(message, line, sourceName, cachedScript); | 248 sanitizeScriptError(message, line, column, sourceName, cachedScript); |
| 245 | 249 |
| 246 ASSERT(!m_inDispatchErrorEvent); | 250 ASSERT(!m_inDispatchErrorEvent); |
| 247 m_inDispatchErrorEvent = true; | 251 m_inDispatchErrorEvent = true; |
| 248 RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line
); | 252 RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line
, column); |
| 249 target->dispatchEvent(errorEvent); | 253 target->dispatchEvent(errorEvent); |
| 250 m_inDispatchErrorEvent = false; | 254 m_inDispatchErrorEvent = false; |
| 251 return errorEvent->defaultPrevented(); | 255 return errorEvent->defaultPrevented(); |
| 252 } | 256 } |
| 253 | 257 |
| 254 int ScriptExecutionContext::circularSequentialID() | 258 int ScriptExecutionContext::circularSequentialID() |
| 255 { | 259 { |
| 256 ++m_circularSequentialID; | 260 ++m_circularSequentialID; |
| 257 if (m_circularSequentialID <= 0) | 261 if (m_circularSequentialID <= 0) |
| 258 m_circularSequentialID = 1; | 262 m_circularSequentialID = 1; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 ScriptExecutionContext::Task::~Task() | 323 ScriptExecutionContext::Task::~Task() |
| 320 { | 324 { |
| 321 } | 325 } |
| 322 | 326 |
| 323 void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext
) | 327 void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext
) |
| 324 { | 328 { |
| 325 m_databaseContext = databaseContext; | 329 m_databaseContext = databaseContext; |
| 326 } | 330 } |
| 327 | 331 |
| 328 } // namespace WebCore | 332 } // namespace WebCore |
| OLD | NEW |