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/Document.cpp

Issue 23163004: Improve 'document.cookie' access check exception messages. (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 | « LayoutTests/fast/frames/sandboxed-iframe-storage-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 9abe48baba00b2f629cdbe1758e65f34139e8011..050ff22c2518762c99e73697c9881e7b1a4322a7 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -3644,7 +3644,13 @@ String Document::cookie(ExceptionState& es) const
// browsing context.
if (!securityOrigin()->canAccessCookies()) {
- es.throwDOMException(SecurityError);
+ String accessDeniedMessage = "Access to 'cookie' is denied for this document.";
+ if (isSandboxed(SandboxOrigin))
+ es.throwSecurityError(accessDeniedMessage + " The document is sandboxed and lacks the 'allow-same-origin' flag.");
+ else if (url().protocolIs("data"))
+ es.throwSecurityError(accessDeniedMessage + " Cookies are disabled inside 'data:' URLs.");
+ else
+ es.throwSecurityError(accessDeniedMessage);
return String();
}
@@ -3665,7 +3671,13 @@ void Document::setCookie(const String& value, ExceptionState& es)
// browsing context.
if (!securityOrigin()->canAccessCookies()) {
- es.throwDOMException(SecurityError);
+ String accessDeniedMessage = "Access to 'cookie' is denied for this document.";
+ if (isSandboxed(SandboxOrigin))
+ es.throwSecurityError(accessDeniedMessage + " The document is sandboxed and lacks the 'allow-same-origin' flag.");
+ else if (url().protocolIs("data"))
+ es.throwSecurityError(accessDeniedMessage + " Cookies are disabled inside 'data:' URLs.");
+ else
+ es.throwSecurityError(accessDeniedMessage);
return;
}
« no previous file with comments | « LayoutTests/fast/frames/sandboxed-iframe-storage-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698