| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 return toRenderWidget(renderer)->widget(); | 304 return toRenderWidget(renderer)->widget(); |
| 305 } | 305 } |
| 306 | 306 |
| 307 static bool acceptsEditingFocus(const Element& element) | 307 static bool acceptsEditingFocus(const Element& element) |
| 308 { | 308 { |
| 309 ASSERT(element.rendererIsEditable()); | 309 ASSERT(element.rendererIsEditable()); |
| 310 | 310 |
| 311 return element.document().frame() && element.rootEditableElement(); | 311 return element.document().frame() && element.rootEditableElement(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 static bool canAccessAncestor(const SecurityOrigin& activeSecurityOrigin, LocalF
rame* targetFrame) | 314 static bool canAccessAncestor(const SecurityOrigin& activeSecurityOrigin, Frame*
targetFrame) |
| 315 { | 315 { |
| 316 // targetFrame can be 0 when we're trying to navigate a top-level frame | 316 // targetFrame can be 0 when we're trying to navigate a top-level frame |
| 317 // that has a 0 opener. | 317 // that has a 0 opener. |
| 318 if (!targetFrame) | 318 if (!targetFrame) |
| 319 return false; | 319 return false; |
| 320 | 320 |
| 321 const bool isLocalActiveOrigin = activeSecurityOrigin.isLocal(); | 321 const bool isLocalActiveOrigin = activeSecurityOrigin.isLocal(); |
| 322 for (LocalFrame* ancestorFrame = targetFrame; ancestorFrame; ancestorFrame =
ancestorFrame->tree().parent()) { | 322 for (Frame* ancestorFrame = targetFrame; ancestorFrame; ancestorFrame = ance
storFrame->tree().parent()) { |
| 323 Document* ancestorDocument = ancestorFrame->document(); | 323 // FIXME: SecurityOrigins need to be refactored to work with out-of-proc
ess iframes. |
| 324 // For now we prevent navigation between cross-process frames. |
| 325 if (!ancestorFrame->isLocalFrame()) |
| 326 return false; |
| 327 |
| 328 Document* ancestorDocument = toLocalFrame(ancestorFrame)->document(); |
| 324 // FIXME: Should be an ASSERT? Frames should alway have documents. | 329 // FIXME: Should be an ASSERT? Frames should alway have documents. |
| 325 if (!ancestorDocument) | 330 if (!ancestorDocument) |
| 326 return true; | 331 return true; |
| 327 | 332 |
| 328 const SecurityOrigin* ancestorSecurityOrigin = ancestorDocument->securit
yOrigin(); | 333 const SecurityOrigin* ancestorSecurityOrigin = ancestorDocument->securit
yOrigin(); |
| 329 if (activeSecurityOrigin.canAccess(ancestorSecurityOrigin)) | 334 if (activeSecurityOrigin.canAccess(ancestorSecurityOrigin)) |
| 330 return true; | 335 return true; |
| 331 | 336 |
| 332 // Allow file URL descendant navigation even when allowFileAccessFromFil
eURLs is false. | 337 // Allow file URL descendant navigation even when allowFileAccessFromFil
eURLs is false. |
| 333 // FIXME: It's a bit strange to special-case local origins here. Should
we be doing | 338 // FIXME: It's a bit strange to special-case local origins here. Should
we be doing |
| (...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2916 } | 2921 } |
| 2917 | 2922 |
| 2918 void Document::disableEval(const String& errorMessage) | 2923 void Document::disableEval(const String& errorMessage) |
| 2919 { | 2924 { |
| 2920 if (!frame()) | 2925 if (!frame()) |
| 2921 return; | 2926 return; |
| 2922 | 2927 |
| 2923 frame()->script().disableEval(errorMessage); | 2928 frame()->script().disableEval(errorMessage); |
| 2924 } | 2929 } |
| 2925 | 2930 |
| 2926 bool Document::canNavigate(LocalFrame* targetFrame) | 2931 bool Document::canNavigate(Frame* targetFrame) |
| 2927 { | 2932 { |
| 2928 if (!m_frame) | 2933 if (!m_frame) |
| 2929 return false; | 2934 return false; |
| 2930 | 2935 |
| 2931 // FIXME: We shouldn't call this function without a target frame, but | 2936 // FIXME: We shouldn't call this function without a target frame, but |
| 2932 // fast/forms/submit-to-blank-multiple-times.html depends on this function | 2937 // fast/forms/submit-to-blank-multiple-times.html depends on this function |
| 2933 // returning true when supplied with a 0 targetFrame. | 2938 // returning true when supplied with a 0 targetFrame. |
| 2934 if (!targetFrame) | 2939 if (!targetFrame) |
| 2935 return true; | 2940 return true; |
| 2936 | 2941 |
| 2937 // LocalFrame-busting is generally allowed, but blocked for sandboxed frames
lacking the 'allow-top-navigation' flag. | 2942 // Frame-busting is generally allowed, but blocked for sandboxed frames lack
ing the 'allow-top-navigation' flag. |
| 2938 if (!isSandboxed(SandboxTopNavigation) && targetFrame == m_frame->tree().top
()) | 2943 if (!isSandboxed(SandboxTopNavigation) && targetFrame == m_frame->tree().top
()) |
| 2939 return true; | 2944 return true; |
| 2940 | 2945 |
| 2941 if (isSandboxed(SandboxNavigation)) { | 2946 if (isSandboxed(SandboxNavigation)) { |
| 2942 if (targetFrame->tree().isDescendantOf(m_frame)) | 2947 if (targetFrame->tree().isDescendantOf(m_frame)) |
| 2943 return true; | 2948 return true; |
| 2944 | 2949 |
| 2945 const char* reason = "The frame attempting navigation is sandboxed, and
is therefore disallowed from navigating its ancestors."; | 2950 const char* reason = "The frame attempting navigation is sandboxed, and
is therefore disallowed from navigating its ancestors."; |
| 2946 if (isSandboxed(SandboxTopNavigation) && targetFrame == m_frame->tree().
top()) | 2951 if (isSandboxed(SandboxTopNavigation) && targetFrame == m_frame->tree().
top()) |
| 2947 reason = "The frame attempting navigation of the top-level window is
sandboxed, but the 'allow-top-navigation' flag is not set."; | 2952 reason = "The frame attempting navigation of the top-level window is
sandboxed, but the 'allow-top-navigation' flag is not set."; |
| 2948 | 2953 |
| 2949 printNavigationErrorMessage(*targetFrame, url(), reason); | 2954 printNavigationErrorMessage(*toLocalFrameTemporary(targetFrame), url(),
reason); |
| 2950 return false; | 2955 return false; |
| 2951 } | 2956 } |
| 2952 | 2957 |
| 2953 ASSERT(securityOrigin()); | 2958 ASSERT(securityOrigin()); |
| 2954 SecurityOrigin& origin = *securityOrigin(); | 2959 SecurityOrigin& origin = *securityOrigin(); |
| 2955 | 2960 |
| 2956 // This is the normal case. A document can navigate its decendant frames, | 2961 // This is the normal case. A document can navigate its decendant frames, |
| 2957 // or, more generally, a document can navigate a frame if the document is | 2962 // or, more generally, a document can navigate a frame if the document is |
| 2958 // in the same origin as any of that frame's ancestors (in the frame | 2963 // in the same origin as any of that frame's ancestors (in the frame |
| 2959 // hierarchy). | 2964 // hierarchy). |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2971 // the top-level frame's opener's ancestors (in the frame hierarchy). | 2976 // the top-level frame's opener's ancestors (in the frame hierarchy). |
| 2972 // | 2977 // |
| 2973 // In both of these cases, the document performing the navigation is in | 2978 // In both of these cases, the document performing the navigation is in |
| 2974 // some way related to the frame being navigate (e.g., by the "opener" | 2979 // some way related to the frame being navigate (e.g., by the "opener" |
| 2975 // and/or "parent" relation). Requiring some sort of relation prevents a | 2980 // and/or "parent" relation). Requiring some sort of relation prevents a |
| 2976 // document from navigating arbitrary, unrelated top-level frames. | 2981 // document from navigating arbitrary, unrelated top-level frames. |
| 2977 if (!targetFrame->tree().parent()) { | 2982 if (!targetFrame->tree().parent()) { |
| 2978 if (targetFrame == m_frame->loader().opener()) | 2983 if (targetFrame == m_frame->loader().opener()) |
| 2979 return true; | 2984 return true; |
| 2980 | 2985 |
| 2981 if (canAccessAncestor(origin, targetFrame->loader().opener())) | 2986 // FIXME: We don't have access to RemoteFrame's opener yet. |
| 2987 if (targetFrame->isLocalFrame() && canAccessAncestor(origin, toLocalFram
e(targetFrame)->loader().opener())) |
| 2982 return true; | 2988 return true; |
| 2983 } | 2989 } |
| 2984 | 2990 |
| 2985 printNavigationErrorMessage(*targetFrame, url(), "The frame attempting navig
ation is neither same-origin with the target, nor is it the target's parent or o
pener."); | 2991 printNavigationErrorMessage(*toLocalFrameTemporary(targetFrame), url(), "The
frame attempting navigation is neither same-origin with the target, nor is it t
he target's parent or opener."); |
| 2986 return false; | 2992 return false; |
| 2987 } | 2993 } |
| 2988 | 2994 |
| 2989 LocalFrame* Document::findUnsafeParentScrollPropagationBoundary() | 2995 LocalFrame* Document::findUnsafeParentScrollPropagationBoundary() |
| 2990 { | 2996 { |
| 2991 LocalFrame* currentFrame = m_frame; | 2997 LocalFrame* currentFrame = m_frame; |
| 2992 LocalFrame* ancestorFrame = currentFrame->tree().parent(); | 2998 Frame* ancestorFrame = currentFrame->tree().parent(); |
| 2993 | 2999 |
| 2994 while (ancestorFrame) { | 3000 while (ancestorFrame) { |
| 2995 if (!ancestorFrame->document()->securityOrigin()->canAccess(securityOrig
in())) | 3001 // FIXME: We don't yet have access to a RemoteFrame's security origin. |
| 3002 if (!ancestorFrame->isLocalFrame()) |
| 2996 return currentFrame; | 3003 return currentFrame; |
| 2997 currentFrame = ancestorFrame; | 3004 if (!toLocalFrame(ancestorFrame)->document()->securityOrigin()->canAcces
s(securityOrigin())) |
| 3005 return currentFrame; |
| 3006 currentFrame = toLocalFrame(ancestorFrame); |
| 2998 ancestorFrame = ancestorFrame->tree().parent(); | 3007 ancestorFrame = ancestorFrame->tree().parent(); |
| 2999 } | 3008 } |
| 3000 return 0; | 3009 return 0; |
| 3001 } | 3010 } |
| 3002 | 3011 |
| 3003 void Document::didLoadAllImports() | 3012 void Document::didLoadAllImports() |
| 3004 { | 3013 { |
| 3005 if (!haveStylesheetsLoaded()) | 3014 if (!haveStylesheetsLoaded()) |
| 3006 return; | 3015 return; |
| 3007 if (!importLoader()) | 3016 if (!importLoader()) |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3227 m_referrerPolicy = referrerPolicy; | 3236 m_referrerPolicy = referrerPolicy; |
| 3228 } | 3237 } |
| 3229 | 3238 |
| 3230 String Document::outgoingReferrer() | 3239 String Document::outgoingReferrer() |
| 3231 { | 3240 { |
| 3232 // See http://www.whatwg.org/specs/web-apps/current-work/#fetching-resources | 3241 // See http://www.whatwg.org/specs/web-apps/current-work/#fetching-resources |
| 3233 // for why we walk the parent chain for srcdoc documents. | 3242 // for why we walk the parent chain for srcdoc documents. |
| 3234 Document* referrerDocument = this; | 3243 Document* referrerDocument = this; |
| 3235 if (LocalFrame* frame = m_frame) { | 3244 if (LocalFrame* frame = m_frame) { |
| 3236 while (frame->document()->isSrcdocDocument()) { | 3245 while (frame->document()->isSrcdocDocument()) { |
| 3246 // Srcdoc documents must be local within the containing frame. |
| 3237 frame = frame->tree().parent(); | 3247 frame = frame->tree().parent(); |
| 3238 // Srcdoc documents cannot be top-level documents, by definition, | 3248 // Srcdoc documents cannot be top-level documents, by definition, |
| 3239 // because they need to be contained in iframes with the srcdoc. | 3249 // because they need to be contained in iframes with the srcdoc. |
| 3240 ASSERT(frame); | 3250 ASSERT(frame); |
| 3241 } | 3251 } |
| 3242 referrerDocument = frame->document(); | 3252 referrerDocument = frame->document(); |
| 3243 } | 3253 } |
| 3244 return referrerDocument->m_url.strippedForUseAsReferrer(); | 3254 return referrerDocument->m_url.strippedForUseAsReferrer(); |
| 3245 } | 3255 } |
| 3246 | 3256 |
| (...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4830 } | 4840 } |
| 4831 | 4841 |
| 4832 m_cookieURL = initializer.owner()->cookieURL(); | 4842 m_cookieURL = initializer.owner()->cookieURL(); |
| 4833 // We alias the SecurityOrigins to match Firefox, see Bug 15313 | 4843 // We alias the SecurityOrigins to match Firefox, see Bug 15313 |
| 4834 // https://bugs.webkit.org/show_bug.cgi?id=15313 | 4844 // https://bugs.webkit.org/show_bug.cgi?id=15313 |
| 4835 setSecurityOrigin(initializer.owner()->securityOrigin()); | 4845 setSecurityOrigin(initializer.owner()->securityOrigin()); |
| 4836 } | 4846 } |
| 4837 | 4847 |
| 4838 void Document::initContentSecurityPolicy(const ContentSecurityPolicyResponseHead
ers& headers) | 4848 void Document::initContentSecurityPolicy(const ContentSecurityPolicyResponseHead
ers& headers) |
| 4839 { | 4849 { |
| 4840 if (m_frame && m_frame->tree().parent() && (shouldInheritSecurityOriginFromO
wner(m_url) || isPluginDocument())) | 4850 if (m_frame && m_frame->tree().parent() && m_frame->tree().parent()->isLocal
Frame() && (shouldInheritSecurityOriginFromOwner(m_url) || isPluginDocument())) |
| 4841 contentSecurityPolicy()->copyStateFrom(m_frame->tree().parent()->documen
t()->contentSecurityPolicy()); | 4851 contentSecurityPolicy()->copyStateFrom(m_frame->tree().parent()->documen
t()->contentSecurityPolicy()); |
| 4842 contentSecurityPolicy()->didReceiveHeaders(headers); | 4852 contentSecurityPolicy()->didReceiveHeaders(headers); |
| 4843 } | 4853 } |
| 4844 | 4854 |
| 4845 bool Document::allowInlineEventHandlers(Node* node, EventListener* listener, con
st String& contextURL, const WTF::OrdinalNumber& contextLine) | 4855 bool Document::allowInlineEventHandlers(Node* node, EventListener* listener, con
st String& contextURL, const WTF::OrdinalNumber& contextLine) |
| 4846 { | 4856 { |
| 4847 if (!contentSecurityPolicy()->allowInlineEventHandlers(contextURL, contextLi
ne)) | 4857 if (!contentSecurityPolicy()->allowInlineEventHandlers(contextURL, contextLi
ne)) |
| 4848 return false; | 4858 return false; |
| 4849 | 4859 |
| 4850 // HTML says that inline script needs browsing context to create its executi
on environment. | 4860 // HTML says that inline script needs browsing context to create its executi
on environment. |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5794 visitor->trace(m_timeline); | 5804 visitor->trace(m_timeline); |
| 5795 visitor->trace(m_compositorPendingAnimations); | 5805 visitor->trace(m_compositorPendingAnimations); |
| 5796 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); | 5806 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); |
| 5797 DocumentSupplementable::trace(visitor); | 5807 DocumentSupplementable::trace(visitor); |
| 5798 TreeScope::trace(visitor); | 5808 TreeScope::trace(visitor); |
| 5799 ContainerNode::trace(visitor); | 5809 ContainerNode::trace(visitor); |
| 5800 ExecutionContext::trace(visitor); | 5810 ExecutionContext::trace(visitor); |
| 5801 } | 5811 } |
| 5802 | 5812 |
| 5803 } // namespace WebCore | 5813 } // namespace WebCore |
| OLD | NEW |