OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 } | 287 } |
288 m_pendingExceptions.clear(); | 288 m_pendingExceptions.clear(); |
289 } | 289 } |
290 | 290 |
291 bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int
lineNumber, const String& sourceURL) | 291 bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int
lineNumber, const String& sourceURL) |
292 { | 292 { |
293 EventTarget* target = errorEventTarget(); | 293 EventTarget* target = errorEventTarget(); |
294 if (!target) | 294 if (!target) |
295 return false; | 295 return false; |
296 | 296 |
| 297 String message; |
| 298 int line; |
| 299 String sourceName; |
| 300 KURL targetUrl = completeURL(sourceURL); |
| 301 if (securityOrigin()->canRequest(targetUrl)) { |
| 302 message = errorMessage; |
| 303 line = lineNumber; |
| 304 sourceName = sourceURL; |
| 305 } else { |
| 306 message = "Script error."; |
| 307 sourceName = String(); |
| 308 line = 0; |
| 309 } |
| 310 |
297 ASSERT(!m_inDispatchErrorEvent); | 311 ASSERT(!m_inDispatchErrorEvent); |
298 m_inDispatchErrorEvent = true; | 312 m_inDispatchErrorEvent = true; |
299 RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(errorMessage, sourceURL,
lineNumber); | 313 RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line
); |
300 target->dispatchEvent(errorEvent); | 314 target->dispatchEvent(errorEvent); |
301 m_inDispatchErrorEvent = false; | 315 m_inDispatchErrorEvent = false; |
302 return errorEvent->defaultPrevented(); | 316 return errorEvent->defaultPrevented(); |
303 } | 317 } |
304 | 318 |
305 void ScriptExecutionContext::addTimeout(int timeoutId, DOMTimer* timer) | 319 void ScriptExecutionContext::addTimeout(int timeoutId, DOMTimer* timer) |
306 { | 320 { |
307 ASSERT(!m_timeouts.contains(timeoutId)); | 321 ASSERT(!m_timeouts.contains(timeoutId)); |
308 m_timeouts.set(timeoutId, timer); | 322 m_timeouts.set(timeoutId, timer); |
309 } | 323 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if (isWorkerContext()) | 378 if (isWorkerContext()) |
365 return static_cast<WorkerContext*>(this)->script()->globalData(); | 379 return static_cast<WorkerContext*>(this)->script()->globalData(); |
366 #endif | 380 #endif |
367 | 381 |
368 ASSERT_NOT_REACHED(); | 382 ASSERT_NOT_REACHED(); |
369 return 0; | 383 return 0; |
370 } | 384 } |
371 #endif | 385 #endif |
372 | 386 |
373 } // namespace WebCore | 387 } // namespace WebCore |
OLD | NEW |