Index: third_party/WebKit/Source/core/dom/Document.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp |
index 26eaa9784d595e6208066fc7919d128cfd9b555a..1a84bb9328df8cad4ea32470cede59edff242276 100644 |
--- a/third_party/WebKit/Source/core/dom/Document.cpp |
+++ b/third_party/WebKit/Source/core/dom/Document.cpp |
@@ -3392,35 +3392,19 @@ bool Document::isSecureContextImpl(String* errorMessage, const SecureContextChec |
// |
// In all cases, a frame must be potentially trustworthy in addition to |
// having an exception listed in order for the exception to be granted. |
- if (SecurityContext::isSandboxed(SandboxOrigin)) { |
- RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url()); |
- if (!isOriginPotentiallyTrustworthy(origin.get(), errorMessage)) |
- return false; |
- if (SchemeRegistry::schemeShouldBypassSecureContextCheck(origin->protocol())) |
- return true; |
- } else { |
- if (!isOriginPotentiallyTrustworthy(securityOrigin(), errorMessage)) |
- return false; |
- if (SchemeRegistry::schemeShouldBypassSecureContextCheck(securityOrigin()->protocol())) |
- return true; |
- } |
+ if (!isOriginPotentiallyTrustworthy(securityOrigin(), errorMessage)) |
+ return false; |
+ if (securityOrigin()->bypassSecureContextCheck()) |
+ return true; |
if (privilegeContextCheck == StandardSecureContextCheck) { |
- Document* context = parentDocument(); |
- while (context) { |
- // Skip to the next ancestor if it's a srcdoc. |
- if (!context->isSrcdocDocument()) { |
- if (context->securityContext().isSandboxed(SandboxOrigin)) { |
- // For a sandboxed origin, use the document's URL. |
- RefPtr<SecurityOrigin> origin = SecurityOrigin::create(context->url()); |
- if (!isOriginPotentiallyTrustworthy(origin.get(), errorMessage)) |
- return false; |
- } else { |
- if (!isOriginPotentiallyTrustworthy(context->securityOrigin(), errorMessage)) |
- return false; |
- } |
- } |
- context = context->parentDocument(); |
+ if (!m_frame) |
+ return true; |
+ Frame* parent = m_frame->tree().parent(); |
+ while (parent) { |
+ if (!isOriginPotentiallyTrustworthy(parent->securityContext()->securityOrigin(), errorMessage)) |
+ return false; |
+ parent = parent->tree().parent(); |
} |
} |
return true; |
@@ -4941,6 +4925,9 @@ void Document::initSecurityContext(const DocumentInit& initializer) |
// In the common case, create the security context from the currently |
// loading URL with a fresh content security policy. |
m_cookieURL = m_url; |
+ // Set the origin initially based on the URL. enforceSandboxFlags() |
+ // will adjust it to be a unique origin if necessary. |
dcheng
2016/02/24 22:11:30
"if necessary": does that mean there are combinati
estark
2016/02/24 22:14:51
I might be misunderstanding the question, but the
|
+ setSecurityOrigin(SecurityOrigin::create(m_url)); |
enforceSandboxFlags(initializer.sandboxFlags()); |
if (initializer.shouldEnforceStrictMixedContentChecking()) |
enforceStrictMixedContentChecking(); |
@@ -4949,7 +4936,6 @@ void Document::initSecurityContext(const DocumentInit& initializer) |
for (auto toUpgrade : *initializer.insecureNavigationsToUpgrade()) |
addInsecureNavigationUpgrade(toUpgrade); |
} |
- setSecurityOrigin(isSandboxed(SandboxOrigin) ? SecurityOrigin::createUnique() : SecurityOrigin::create(m_url)); |
if (importsController()) { |
// If this document is an HTML import, grab a reference to it's master document's Content |
@@ -4995,9 +4981,12 @@ void Document::initSecurityContext(const DocumentInit& initializer) |
if (isSandboxed(SandboxOrigin)) { |
// If we're supposed to inherit our security origin from our owner, |
- // but we're also sandboxed, the only thing we inherit is the ability |
- // to load local resources. This lets about:blank iframes in file:// |
+ // but we're also sandboxed, the only things we inherit are the |
+ // potential trustworthiness of the origin and the ability to |
+ // load local resources. This lets about:blank iframes in file:// |
alexmos
2016/02/26 19:21:57
nit: perhaps s/This/The latter/ or something simil
estark
2016/03/01 02:59:26
Done.
|
// URL documents load images and other resources from the file system. |
+ if (initializer.owner()->securityOrigin()->isPotentiallyTrustworthy()) |
+ securityOrigin()->setIsPotentiallyTrustworthySandboxedOrigin(); |
if (initializer.owner()->securityOrigin()->canLoadLocalResources()) |
securityOrigin()->grantLoadLocalResources(); |
return; |