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

Unified Diff: Source/bindings/v8/BindingSecurity.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: 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
Index: Source/bindings/v8/BindingSecurity.cpp
diff --git a/Source/bindings/v8/BindingSecurity.cpp b/Source/bindings/v8/BindingSecurity.cpp
index ab23d1ff06709172f59e474a3e78a7ec55fee759..4bcb0f23eb9fef37e709462c5ec56352a341eb6d 100644
--- a/Source/bindings/v8/BindingSecurity.cpp
+++ b/Source/bindings/v8/BindingSecurity.cpp
@@ -34,7 +34,6 @@
#include "bindings/v8/V8Binding.h"
#include "core/dom/Document.h"
#include "core/html/HTMLFrameElementBase.h"
-#include "core/html/parser/HTMLParserIdioms.h"
#include "core/page/DOMWindow.h"
#include "core/page/Frame.h"
#include "core/page/Settings.h"
@@ -42,7 +41,7 @@
namespace WebCore {
-static bool canAccessDocument(Document* targetDocument, SecurityReportingOption reportingOption = ReportSecurityError)
+static bool isDocumentAccessibleFromActiveDOMWindow(Document* targetDocument)
{
if (!targetDocument)
return false;
@@ -54,9 +53,26 @@ static bool canAccessDocument(Document* targetDocument, SecurityReportingOption
if (active->document()->securityOrigin()->canAccess(targetDocument->securityOrigin()))
return true;
+ return false;
+}
+
+static bool canAccessDocument(Document* targetDocument, ExceptionState& es)
abarth-chromium 2013/08/12 19:57:03 What's the point of having this be a separate func
Mike West 2013/08/13 08:30:51 This is the first patch that throws an exception o
+{
+ if (isDocumentAccessibleFromActiveDOMWindow(targetDocument))
+ return true;
+
+ es.throwDOMException(SecurityError, targetDocument->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow()));
abarth-chromium 2013/08/12 19:58:26 Wait a minute. not lgtm. This leaks the current
+ return false;
+}
+
+static bool canAccessDocument(Document* targetDocument, SecurityReportingOption reportingOption = ReportSecurityError)
+{
+ if (isDocumentAccessibleFromActiveDOMWindow(targetDocument))
+ return true;
+
if (reportingOption == ReportSecurityError) {
if (Frame* frame = targetDocument->frame())
- frame->domWindow()->printErrorMessage(targetDocument->domWindow()->crossDomainAccessErrorMessage(active));
+ frame->domWindow()->printErrorMessage(targetDocument->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow()));
abarth-chromium 2013/08/12 19:57:03 It's kine of lame that we call activeDOMWindow twi
Mike West 2013/08/13 08:30:51 Good point. Fixed.
}
return false;
@@ -67,14 +83,14 @@ bool BindingSecurity::shouldAllowAccessToFrame(Frame* target, SecurityReportingO
return target && canAccessDocument(target->document(), reportingOption);
}
-bool BindingSecurity::shouldAllowAccessToNode(Node* target)
+bool BindingSecurity::shouldAllowAccessToFrame(Frame* target, ExceptionState& es)
{
- return target && canAccessDocument(target->document());
+ return target && canAccessDocument(target->document(), es);
}
-bool BindingSecurity::allowSettingFrameSrcToJavascriptUrl(HTMLFrameElementBase* frame, const String& value)
+bool BindingSecurity::shouldAllowAccessToNode(Node* target)
{
- return !protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value)) || canAccessDocument(frame->contentDocument());
+ return target && canAccessDocument(target->document());
}
}

Powered by Google App Engine
This is Rietveld 408576698