Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: Source/core/dom/ScriptExecutionContext.cpp

Issue 20351002: Add 'error' parameter to 'window.onerror' handlers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/ScriptExecutionContext.cpp
diff --git a/Source/core/dom/ScriptExecutionContext.cpp b/Source/core/dom/ScriptExecutionContext.cpp
index 6c0b2101c5dfe6e21e924cc2f016b092ca95ca7e..8e525b7b1905d1235303ccd14d01f175bb29401d 100644
--- a/Source/core/dom/ScriptExecutionContext.cpp
+++ b/Source/core/dom/ScriptExecutionContext.cpp
@@ -28,6 +28,7 @@
#include "config.h"
#include "core/dom/ScriptExecutionContext.h"
+#include "bindings/v8/SerializedScriptValue.h"
#include "core/dom/ContextLifecycleNotifier.h"
#include "core/dom/ErrorEvent.h"
#include "core/dom/EventTarget.h"
@@ -195,7 +196,7 @@ void ScriptExecutionContext::closeMessagePorts() {
}
}
-bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, CachedScript* cachedScript)
+bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, ScriptValue& error, CachedScript* cachedScript)
{
KURL targetURL = completeURL(sourceURL);
if (securityOrigin()->canRequest(targetURL) || (cachedScript && cachedScript->passesAccessControlCheck(securityOrigin())))
@@ -204,10 +205,11 @@ bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& line
sourceURL = String();
lineNumber = 0;
columnNumber = 0;
+ error.clear();
return true;
}
-void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack, CachedScript* cachedScript)
+void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack, const ScriptValue& error, CachedScript* cachedScript)
{
if (m_inDispatchErrorEvent) {
if (!m_pendingExceptions)
@@ -217,7 +219,7 @@ void ScriptExecutionContext::reportException(const String& errorMessage, int lin
}
// First report the original exception and only then all the nested ones.
- if (!dispatchErrorEvent(errorMessage, lineNumber, columnNumber, sourceURL, cachedScript))
+ if (!dispatchErrorEvent(errorMessage, lineNumber, columnNumber, sourceURL, error, cachedScript))
logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, callStack);
if (!m_pendingExceptions)
@@ -235,7 +237,7 @@ void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLeve
addMessage(source, level, message, sourceURL, lineNumber, 0, state, requestIdentifier);
}
-bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, CachedScript* cachedScript)
+bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, const ScriptValue& errorObject, CachedScript* cachedScript)
{
EventTarget* target = errorEventTarget();
if (!target)
@@ -245,11 +247,12 @@ bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int
int line = lineNumber;
int column = columnNumber;
String sourceName = sourceURL;
- sanitizeScriptError(message, line, column, sourceName, cachedScript);
+ ScriptValue error = errorObject;
+ sanitizeScriptError(message, line, column, sourceName, error, cachedScript);
ASSERT(!m_inDispatchErrorEvent);
m_inDispatchErrorEvent = true;
- RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line, column);
+ RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line, column, error);
target->dispatchEvent(errorEvent);
m_inDispatchErrorEvent = false;
return errorEvent->defaultPrevented();

Powered by Google App Engine
This is Rietveld 408576698