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

Unified Diff: Source/core/page/DOMWindow.cpp

Issue 22829002: Throw an exception when denying access to 'Frame's 'location' setter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Less insecurity. 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
Index: Source/core/page/DOMWindow.cpp
diff --git a/Source/core/page/DOMWindow.cpp b/Source/core/page/DOMWindow.cpp
index aac917c7d460f71f8166df98d1422cefba3cf79c..1cc54c5949b3c21647797d0d0d8154c8498a784b 100644
--- a/Source/core/page/DOMWindow.cpp
+++ b/Source/core/page/DOMWindow.cpp
@@ -1571,6 +1571,27 @@ void DOMWindow::printErrorMessage(const String& message)
pageConsole()->addMessage(JSMessageSource, ErrorMessageLevel, message);
}
+// FIXME: Once we're throwing exceptions for cross-origin access violations, we will always sanitize the target
+// frame details, so we can safely combine 'crossDomainAccessErrorMessage' with this method after considering
+// exactly which details may be exposed to JavaScript.
+//
+// http://crbug.com/17325
+String DOMWindow::sanitizedCrossDomainAccessErrorMessage(DOMWindow* activeWindow)
+{
+ const KURL& activeWindowURL = activeWindow->document()->url();
+ if (activeWindowURL.isNull())
+ return String();
+
+ ASSERT(!activeWindow->document()->securityOrigin()->canAccess(document()->securityOrigin()));
+
+ SecurityOrigin* activeOrigin = activeWindow->document()->securityOrigin();
+ String message = "Blocked a frame with origin \"" + activeOrigin->toString() + "\" from accessing a cross-origin frame.";
+
+ // FIXME: Evaluate which details from 'crossDomainAccessErrorMessage' may safely be reported to JavaScript.
+
+ return message;
+}
+
String DOMWindow::crossDomainAccessErrorMessage(DOMWindow* activeWindow)
{
const KURL& activeWindowURL = activeWindow->document()->url();

Powered by Google App Engine
This is Rietveld 408576698