<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[244589] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/244589">244589</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2019-04-24 08:43:09 -0700 (Wed, 24 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>X-Frame-Options header should be ignored when frame-ancestors CSP directive is present
https://bugs.webkit.org/show_bug.cgi?id=197226
<rdar://problem/50155649>

Reviewed by Alex Christensen.

Source/WebCore:

X-Frame-Options header should be ignored when frame-ancestors CSP directive is present:
- https://www.w3.org/TR/CSP3/#frame-ancestors-and-frame-options

Specification says:
"""
In order to allow backwards-compatible deployment, the frame-ancestors directive _obsoletes_ the
X-Frame-Options header. If a resource is delivered with an policy that includes a directive named
frame-ancestors and whose disposition is "enforce", then the X-Frame-Options header MUST be ignored.
"""

Gecko and Blink follow the specification, WebKit does not. As a result, page [1] is broken with
WebKit-only on Schwab.com. The page height is wrong and you cannot see all the ETFs as a result.

[1] https://www.schwab.com/public/schwab/investing/investment_help/investment_research/etf_research/etfs.html?&path=/Prospect/Research/etfs/overview/oneSourceETFs.asp

Test: http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options.html

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::responseReceived):
* page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::overridesXFrameOptions const):
* page/csp/ContentSecurityPolicy.h:
* page/csp/ContentSecurityPolicyDirectiveList.h:
(WebCore::ContentSecurityPolicyDirectiveList::hasFrameAncestorsDirective const):

Source/WebKit:

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::shouldInterruptLoadForCSPFrameAncestorsOrXFrameOptions):

LayoutTests:

Add layout test coverage.

* http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options.html: Added.
* http/tests/security/contentSecurityPolicy/resources/frame-ancestors-self-x-frame-options-deny.pl: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentLoadercpp">trunk/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorepagecspContentSecurityPolicycpp">trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp</a></li>
<li><a href="#trunkSourceWebCorepagecspContentSecurityPolicyh">trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h</a></li>
<li><a href="#trunkSourceWebCorepagecspContentSecurityPolicyDirectiveListh">trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkResourceLoadercpp">trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicy11frameancestorsframeancestorsoverridesXFramesOptionsexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicy11frameancestorsframeancestorsoverridesXFramesOptionshtml">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyresourcesframeancestorsselfxframeoptionsdenypl">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/frame-ancestors-self-x-frame-options-deny.pl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (244588 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-04-24 15:38:23 UTC (rev 244588)
+++ trunk/LayoutTests/ChangeLog 2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2019-04-24  Chris Dumez  <cdumez@apple.com>
+
+        X-Frame-Options header should be ignored when frame-ancestors CSP directive is present
+        https://bugs.webkit.org/show_bug.cgi?id=197226
+        <rdar://problem/50155649>
+
+        Reviewed by Alex Christensen.
+
+        Add layout test coverage.
+
+        * http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options-expected.txt: Added.
+        * http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options.html: Added.
+        * http/tests/security/contentSecurityPolicy/resources/frame-ancestors-self-x-frame-options-deny.pl: Added.
+
</ins><span class="cx"> 2019-04-24  chris fleizach  <cfleizach@apple.com>
</span><span class="cx"> 
</span><span class="cx">         AX: Remove deprecated Accessibility Object Model events
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicy11frameancestorsframeancestorsoverridesXFramesOptionsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options-expected.txt (0 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options-expected.txt                          (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options-expected.txt     2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+X-Frame-Options should be ignored if frame-ancestors directive is present
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS X-Frame-Options was ignored
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicy11frameancestorsframeancestorsoverridesXFramesOptionshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options.html (0 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options.html                          (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options.html     2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+description("X-Frame-Options should be ignored if frame-ancestors directive is present");
+jsTestIsAsync = true;
+
+function finish() 
+{
+    if (testFrame.contentDocument && testFrame.contentDocument.URL === "http://127.0.0.1:8000/security/contentSecurityPolicy/resources/frame-ancestors-self-x-frame-options-deny.pl")
+        testPassed("X-Frame-Options was ignored");
+    else
+        testFailed("X-Frame-Options was not ignored");
+    finishJSTest();
+}
+</script>
+<iframe id="testFrame" src="../../resources/frame-ancestors-self-x-frame-options-deny.pl" onload="finish()" onerror="finish()"></iframe>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyresourcesframeancestorsselfxframeoptionsdenypl"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/frame-ancestors-self-x-frame-options-deny.pl (0 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/frame-ancestors-self-x-frame-options-deny.pl                               (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/frame-ancestors-self-x-frame-options-deny.pl  2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+#!/usr/bin/perl
+use strict;
+
+print "Content-Type: text/html; charset=UTF-8\n";
+print "Content-Security-Policy: frame-ancestors 'self'\n";
+print "X-Frame-Options: deny\n\n";
+
+print "<!DOCTYPE html>\n";
+print "<html>\n";
+print "<body>\n";
+print "    <p>This is an IFrame sending a Content Security Policy header containing \"frame-ancestors self\" and a \"X-Frame-Options: deny\" header.</p>\n";
+print "</body>\n";
+print "</html>\n";
</ins><span class="cx">Property changes on: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/frame-ancestors-self-x-frame-options-deny.pl
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnexecutable"></a>
<div class="addfile"><h4>Added: svn:executable</h4></div>
<ins>+*
</ins><span class="cx">\ No newline at end of property
</span><a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244588 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-04-24 15:38:23 UTC (rev 244588)
+++ trunk/Source/WebCore/ChangeLog      2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2019-04-24  Chris Dumez  <cdumez@apple.com>
+
+        X-Frame-Options header should be ignored when frame-ancestors CSP directive is present
+        https://bugs.webkit.org/show_bug.cgi?id=197226
+        <rdar://problem/50155649>
+
+        Reviewed by Alex Christensen.
+
+        X-Frame-Options header should be ignored when frame-ancestors CSP directive is present:
+        - https://www.w3.org/TR/CSP3/#frame-ancestors-and-frame-options
+
+        Specification says:
+        """
+        In order to allow backwards-compatible deployment, the frame-ancestors directive _obsoletes_ the
+        X-Frame-Options header. If a resource is delivered with an policy that includes a directive named
+        frame-ancestors and whose disposition is "enforce", then the X-Frame-Options header MUST be ignored.
+        """
+
+        Gecko and Blink follow the specification, WebKit does not. As a result, page [1] is broken with
+        WebKit-only on Schwab.com. The page height is wrong and you cannot see all the ETFs as a result.
+
+        [1] https://www.schwab.com/public/schwab/investing/investment_help/investment_research/etf_research/etfs.html?&path=/Prospect/Research/etfs/overview/oneSourceETFs.asp
+
+        Test: http/tests/security/contentSecurityPolicy/1.1/frame-ancestors/frame-ancestors-overrides-X-Frames-Options.html
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::responseReceived):
+        * page/csp/ContentSecurityPolicy.cpp:
+        (WebCore::ContentSecurityPolicy::overridesXFrameOptions const):
+        * page/csp/ContentSecurityPolicy.h:
+        * page/csp/ContentSecurityPolicyDirectiveList.h:
+        (WebCore::ContentSecurityPolicyDirectiveList::hasFrameAncestorsDirective const):
+
</ins><span class="cx"> 2019-04-24  Zalan Bujtas  <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [ContentChangeObserver] Do not use the global _WKContentChange in WebKitLegacy
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (244588 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentLoader.cpp   2019-04-24 15:38:23 UTC (rev 244588)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp      2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -787,13 +787,15 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        String frameOptions = response.httpHeaderFields().get(HTTPHeaderName::XFrameOptions);
-        if (!frameOptions.isNull()) {
-            if (frameLoader()->shouldInterruptLoadForXFrameOptions(frameOptions, url, identifier)) {
-                String message = "Refused to display '" + url.stringCenterEllipsizedToLength() + "' in a frame because it set 'X-Frame-Options' to '" + frameOptions + "'.";
-                m_frame->document()->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, identifier);
-                stopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied(identifier, response);
-                return;
</del><ins>+        if (!contentSecurityPolicy.overridesXFrameOptions()) {
+            String frameOptions = response.httpHeaderFields().get(HTTPHeaderName::XFrameOptions);
+            if (!frameOptions.isNull()) {
+                if (frameLoader()->shouldInterruptLoadForXFrameOptions(frameOptions, url, identifier)) {
+                    String message = "Refused to display '" + url.stringCenterEllipsizedToLength() + "' in a frame because it set 'X-Frame-Options' to '" + frameOptions + "'.";
+                    m_frame->document()->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, identifier);
+                    stopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied(identifier, response);
+                    return;
+                }
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorepagecspContentSecurityPolicycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp (244588 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp  2019-04-24 15:38:23 UTC (rev 244588)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp     2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -500,6 +500,18 @@
</span><span class="cx">     return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForFrameAncestor, frame);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool ContentSecurityPolicy::overridesXFrameOptions() const
+{
+    // If a resource is delivered with an policy that includes a directive named frame-ancestors and whose disposition
+    // is "enforce", then the X-Frame-Options header MUST be ignored.
+    // https://www.w3.org/TR/CSP3/#frame-ancestors-and-frame-options
+    for (auto& policy : m_policies) {
+        if (!policy->isReportOnly() && policy->hasFrameAncestorsDirective())
+            return true;
+    }
+    return false;
+}
+
</ins><span class="cx"> bool ContentSecurityPolicy::allowFrameAncestors(const Vector<RefPtr<SecurityOrigin>>& ancestorOrigins, const URL& url, bool overrideContentSecurityPolicy) const
</span><span class="cx"> {
</span><span class="cx">     if (overrideContentSecurityPolicy)
</span></span></pre></div>
<a id="trunkSourceWebCorepagecspContentSecurityPolicyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h (244588 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h    2019-04-24 15:38:23 UTC (rev 244588)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h       2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -99,6 +99,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool allowFrameAncestors(const Frame&, const URL&, bool overrideContentSecurityPolicy = false) const;
</span><span class="cx">     WEBCORE_EXPORT bool allowFrameAncestors(const Vector<RefPtr<SecurityOrigin>>& ancestorOrigins, const URL&, bool overrideContentSecurityPolicy = false) const;
</span><ins>+    WEBCORE_EXPORT bool overridesXFrameOptions() const;
</ins><span class="cx"> 
</span><span class="cx">     enum class RedirectResponseReceived { No, Yes };
</span><span class="cx">     WEBCORE_EXPORT bool allowScriptFromSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No) const;
</span></span></pre></div>
<a id="trunkSourceWebCorepagecspContentSecurityPolicyDirectiveListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.h (244588 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.h       2019-04-24 15:38:23 UTC (rev 244588)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.h  2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -76,6 +76,7 @@
</span><span class="cx">     const ContentSecurityPolicyDirective* defaultSrc() const { return m_defaultSrc.get(); }
</span><span class="cx"> 
</span><span class="cx">     bool hasBlockAllMixedContentDirective() const { return m_hasBlockAllMixedContentDirective; }
</span><ins>+    bool hasFrameAncestorsDirective() const { return !!m_frameAncestors; }
</ins><span class="cx"> 
</span><span class="cx">     const String& evalDisabledErrorMessage() const { return m_evalDisabledErrorMessage; }
</span><span class="cx">     const String& webAssemblyDisabledErrorMessage() const { return m_webAssemblyDisabledErrorMessage; }
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (244588 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-04-24 15:38:23 UTC (rev 244588)
+++ trunk/Source/WebKit/ChangeLog       2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2019-04-24  Chris Dumez  <cdumez@apple.com>
+
+        X-Frame-Options header should be ignored when frame-ancestors CSP directive is present
+        https://bugs.webkit.org/show_bug.cgi?id=197226
+        <rdar://problem/50155649>
+
+        Reviewed by Alex Christensen.
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::shouldInterruptLoadForCSPFrameAncestorsOrXFrameOptions):
+
</ins><span class="cx"> 2019-04-24  Dean Jackson  <dino@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Rename _highlightLongPressCanClick and only add gesture recognizer when necessary
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (244588 => 244589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp     2019-04-24 15:38:23 UTC (rev 244588)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp        2019-04-24 15:43:09 UTC (rev 244589)
</span><span class="lines">@@ -396,11 +396,14 @@
</span><span class="cx">     contentSecurityPolicy.didReceiveHeaders(ContentSecurityPolicyResponseHeaders { response }, originalRequest().httpReferrer());
</span><span class="cx">     if (!contentSecurityPolicy.allowFrameAncestors(m_parameters.frameAncestorOrigins, url))
</span><span class="cx">         return true;
</span><del>-    String xFrameOptions = m_response.httpHeaderField(HTTPHeaderName::XFrameOptions);
-    if (!xFrameOptions.isNull() && shouldInterruptLoadForXFrameOptions(xFrameOptions, response.url())) {
-        String errorMessage = "Refused to display '" + response.url().stringCenterEllipsizedToLength() + "' in a frame because it set 'X-Frame-Options' to '" + xFrameOptions + "'.";
-        send(Messages::WebPage::AddConsoleMessage { m_parameters.webFrameID,  MessageSource::Security, MessageLevel::Error, errorMessage, identifier() }, m_parameters.webPageID);
-        return true;
</del><ins>+
+    if (!contentSecurityPolicy.overridesXFrameOptions()) {
+        String xFrameOptions = m_response.httpHeaderField(HTTPHeaderName::XFrameOptions);
+        if (!xFrameOptions.isNull() && shouldInterruptLoadForXFrameOptions(xFrameOptions, response.url())) {
+            String errorMessage = "Refused to display '" + response.url().stringCenterEllipsizedToLength() + "' in a frame because it set 'X-Frame-Options' to '" + xFrameOptions + "'.";
+            send(Messages::WebPage::AddConsoleMessage { m_parameters.webFrameID,  MessageSource::Security, MessageLevel::Error, errorMessage, identifier() }, m_parameters.webPageID);
+            return true;
+        }
</ins><span class="cx">     }
</span><span class="cx">     return false;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>