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

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: Rebase. Created 7 years, 4 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
« no previous file with comments | « Source/core/dom/ScriptExecutionContext.h ('k') | Source/core/dom/ScriptLoader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ScriptExecutionContext.cpp
diff --git a/Source/core/dom/ScriptExecutionContext.cpp b/Source/core/dom/ScriptExecutionContext.cpp
index 42e04fb56a91d2c57547429e91cb213219bb98f9..13191d8e48caefdc44e01d7cfa70cef40f893733 100644
--- a/Source/core/dom/ScriptExecutionContext.cpp
+++ b/Source/core/dom/ScriptExecutionContext.cpp
@@ -194,23 +194,12 @@ void ScriptExecutionContext::closeMessagePorts() {
}
}
-bool ScriptExecutionContext::shouldSanitizeScriptError(const String& sourceURL)
+bool ScriptExecutionContext::shouldSanitizeScriptError(const String& sourceURL, AccessControlStatus corsStatus)
{
- return !securityOrigin()->canRequest(completeURL(sourceURL));
+ return !(securityOrigin()->canRequest(completeURL(sourceURL)) || corsStatus == SharableCrossOrigin);
}
-bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL)
-{
- if (!shouldSanitizeScriptError(sourceURL))
- return false;
- errorMessage = "Script error.";
- sourceURL = String();
- lineNumber = 0;
- columnNumber = 0;
- return true;
-}
-
-void ScriptExecutionContext::reportException(PassRefPtr<ErrorEvent> event, PassRefPtr<ScriptCallStack> callStack)
+void ScriptExecutionContext::reportException(PassRefPtr<ErrorEvent> event, PassRefPtr<ScriptCallStack> callStack, AccessControlStatus corsStatus)
{
RefPtr<ErrorEvent> errorEvent = event;
if (m_inDispatchErrorEvent) {
@@ -221,7 +210,7 @@ void ScriptExecutionContext::reportException(PassRefPtr<ErrorEvent> event, PassR
}
// First report the original exception and only then all the nested ones.
- if (!dispatchErrorEvent(errorEvent))
+ if (!dispatchErrorEvent(errorEvent, corsStatus))
logExceptionToConsole(errorEvent->message(), errorEvent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack);
if (!m_pendingExceptions)
@@ -239,14 +228,14 @@ void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLeve
addMessage(source, level, message, sourceURL, lineNumber, 0, state, requestIdentifier);
}
-bool ScriptExecutionContext::dispatchErrorEvent(PassRefPtr<ErrorEvent> event)
+bool ScriptExecutionContext::dispatchErrorEvent(PassRefPtr<ErrorEvent> event, AccessControlStatus corsStatus)
{
EventTarget* target = errorEventTarget();
if (!target)
return false;
RefPtr<ErrorEvent> errorEvent = event;
- if (shouldSanitizeScriptError(errorEvent->filename()))
+ if (shouldSanitizeScriptError(errorEvent->filename(), corsStatus))
errorEvent = ErrorEvent::createSanitizedError();
ASSERT(!m_inDispatchErrorEvent);
« no previous file with comments | « Source/core/dom/ScriptExecutionContext.h ('k') | Source/core/dom/ScriptLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698