Index: Source/core/fetch/CrossOriginAccessControl.cpp |
diff --git a/Source/core/fetch/CrossOriginAccessControl.cpp b/Source/core/fetch/CrossOriginAccessControl.cpp |
index ddcb29c406424386cc69bfafc051b9d6f413c30a..76040fb3b778d27f4c9b3166a92af542822f4c2a 100644 |
--- a/Source/core/fetch/CrossOriginAccessControl.cpp |
+++ b/Source/core/fetch/CrossOriginAccessControl.cpp |
@@ -142,6 +142,14 @@ static bool isOriginSeparator(UChar ch) |
return isASCIISpace(ch) || ch == ','; |
} |
+static bool isInterestingStatusCode(int statusCode) |
+{ |
+ // Predicate that gates what status codes should be included in |
+ // console error messages for responses containing no access |
+ // control headers. |
+ return statusCode >= 400; |
+} |
+ |
bool passesAccessControlCheck(const ResourceResponse& response, StoredCredentials includeCredentials, SecurityOrigin* securityOrigin, String& errorDescription) |
{ |
AtomicallyInitializedStatic(AtomicString&, accessControlAllowOrigin = *new AtomicString("access-control-allow-origin", AtomicString::ConstructFromLiteral)); |
@@ -165,6 +173,9 @@ bool passesAccessControlCheck(const ResourceResponse& response, StoredCredential |
} else if (accessControlOriginString != securityOrigin->toAtomicString()) { |
if (accessControlOriginString.isEmpty()) { |
errorDescription = "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '" + securityOrigin->toString() + "' is therefore not allowed access."; |
+ |
+ if (isInterestingStatusCode(response.httpStatusCode())) |
+ errorDescription.append(" The response had HTTP status code " + String::number(response.httpStatusCode()) + "."); |
} else if (accessControlOriginString.string().find(isOriginSeparator, 0) != kNotFound) { |
errorDescription = "The 'Access-Control-Allow-Origin' header contains multiple values '" + accessControlOriginString + "', but only one is allowed. Origin '" + securityOrigin->toString() + "' is therefore not allowed access."; |
} else { |