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

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

Issue 19596004: Allow sites to enable 'window.onerror' handlers for cross-domain scripts. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rework. 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 ff466ba50c62691668ca73cb576396de04f1a26e..58e00ad8dd9e429ea59b7a1eb110102887b297f0 100644
--- a/Source/core/dom/ScriptExecutionContext.cpp
+++ b/Source/core/dom/ScriptExecutionContext.cpp
@@ -194,11 +194,11 @@ void ScriptExecutionContext::closeMessagePorts() {
}
}
-bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL)
+bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, ScriptAccessControlCheckStatus corsStatus)
{
- KURL targetURL = completeURL(sourceURL);
- if (securityOrigin()->canRequest(targetURL))
+ if (corsStatus == ScriptIsSharedCrossOrigin || securityOrigin()->canRequest(completeURL(sourceURL)))
return false;
+
errorMessage = "Script error.";
sourceURL = String();
lineNumber = 0;
@@ -206,7 +206,7 @@ bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& line
return true;
}
-void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
+void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack, ScriptAccessControlCheckStatus corsStatus)
{
if (m_inDispatchErrorEvent) {
if (!m_pendingExceptions)
@@ -216,7 +216,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))
+ if (!dispatchErrorEvent(errorMessage, lineNumber, columnNumber, sourceURL, corsStatus))
logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, callStack);
if (!m_pendingExceptions)
@@ -234,7 +234,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)
+bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, ScriptAccessControlCheckStatus corsStatus)
{
EventTarget* target = errorEventTarget();
if (!target)
@@ -244,7 +244,7 @@ bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int
int line = lineNumber;
int column = columnNumber;
String sourceName = sourceURL;
- sanitizeScriptError(message, line, column, sourceName);
+ sanitizeScriptError(message, line, column, sourceName, corsStatus);
abarth-chromium 2013/08/05 22:31:45 This sort of function is crying out for a struct p
Mike West 2013/08/06 06:53:07 Sure, I can do that.
Mike West 2013/08/06 07:54:03 As it turns out, we can remove this method entirel
ASSERT(!m_inDispatchErrorEvent);
m_inDispatchErrorEvent = true;

Powered by Google App Engine
This is Rietveld 408576698