<!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>[203611] 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/203611">203611</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2016-07-22 13:33:11 -0700 (Fri, 22 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>CSP: object-src and plugin-types directives are not respected for plugin replacements
https://bugs.webkit.org/show_bug.cgi?id=159761
&lt;rdar://problem/27365724&gt;

Reviewed by Brent Fulgham.

Source/WebCore:

Apply the Content Security Policy (CSP) object-src and plugin-types directives to content that will
load with a plugin replacement.

Tests: security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement.html
       security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement.html
       security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement.html
       security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement.html
       security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type.html
       security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement.html
       security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html
       security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html

* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::allowedToLoadPluginContent): Added.
(WebCore::HTMLPlugInImageElement::requestObject): Only request loading plugin content if we
are allowed to load such content.
* html/HTMLPlugInImageElement.h:
* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::pluginIsLoadable): Removed code to check CSP as we will check CSP
earlier in HTMLPlugInImageElement::requestObject().
(WebCore::SubframeLoader::requestPlugin): Ditto.
(WebCore::SubframeLoader::isPluginContentAllowedByContentSecurityPolicy): Deleted; moved implementation
to HTMLPlugInImageElement::allowedToLoadPluginContent().
(WebCore::SubframeLoader::requestObject): Deleted.
* loader/SubframeLoader.h:
* page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::upgradeInsecureRequestIfNeeded): Changed signature from a non-const
function to a const function since these functions do not modify |this|.
* page/csp/ContentSecurityPolicy.h:

LayoutTests:

Add layout tests to ensure that we apply the CSP object-src and plugin-types directives to content
that loads with either the QuickTime plugin replacement or YouTube plugin replacement.

* security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement-expected.txt: Added.
* security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement.html: Added.
* security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement-expected.txt: Added.
* security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement.html: Added.
* security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement-expected.txt: Added.
* security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement.html: Added.
* security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement-expected.txt: Added.
* security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement.html: Added.
* security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-expected.txt: Added.
* security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type-expected.txt: Added.
* security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type.html: Added.
* security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement.html: Added.
* security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-expected.txt: Added.
* security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type-expected.txt: Added.
* security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html: Added.
* security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html: 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="#trunkSourceWebCorehtmlHTMLPlugInImageElementcpp">trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLPlugInImageElementh">trunk/Source/WebCore/html/HTMLPlugInImageElement.h</a></li>
<li><a href="#trunkSourceWebCoreloaderSubframeLoadercpp">trunk/Source/WebCore/loader/SubframeLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderSubframeLoaderh">trunk/Source/WebCore/loader/SubframeLoader.h</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>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicyobjectsrcnoneblocksquicktimepluginreplacementexpectedtxt">trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicyobjectsrcnoneblocksquicktimepluginreplacementhtml">trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement.html</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicyobjectsrcnoneblocksyoutubepluginreplacementexpectedtxt">trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicyobjectsrcnoneblocksyoutubepluginreplacementhtml">trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement.html</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesallowsquicktimepluginreplacementexpectedtxt">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesallowsquicktimepluginreplacementhtml">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement.html</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesallowsyoutubepluginreplacementexpectedtxt">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesallowsyoutubepluginreplacementhtml">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement.html</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksquicktimepluginreplacementexpectedtxt">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksquicktimepluginreplacementwithoutmimetypeexpectedtxt">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type-expected.txt</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksquicktimepluginreplacementwithoutmimetypehtml">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type.html</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksquicktimepluginreplacementhtml">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement.html</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksyoutubepluginreplacementexpectedtxt">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-expected.txt</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksyoutubepluginreplacementwithoutmimetypeexpectedtxt">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type-expected.txt</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksyoutubepluginreplacementwithoutmimetypehtml">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html</a></li>
<li><a href="#trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksyoutubepluginreplacementhtml">trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (203610 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-22 19:54:13 UTC (rev 203610)
+++ trunk/LayoutTests/ChangeLog        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-07-22  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        CSP: object-src and plugin-types directives are not respected for plugin replacements
+        https://bugs.webkit.org/show_bug.cgi?id=159761
+        &lt;rdar://problem/27365724&gt;
+
+        Reviewed by Brent Fulgham.
+
+        Add layout tests to ensure that we apply the CSP object-src and plugin-types directives to content
+        that loads with either the QuickTime plugin replacement or YouTube plugin replacement.
+
+        * security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement-expected.txt: Added.
+        * security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement.html: Added.
+        * security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement-expected.txt: Added.
+        * security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement.html: Added.
+        * security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement-expected.txt: Added.
+        * security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement.html: Added.
+        * security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement-expected.txt: Added.
+        * security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement.html: Added.
+        * security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-expected.txt: Added.
+        * security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type-expected.txt: Added.
+        * security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type.html: Added.
+        * security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement.html: Added.
+        * security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-expected.txt: Added.
+        * security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type-expected.txt: Added.
+        * security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html: Added.
+        * security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html: Added.
+
</ins><span class="cx"> 2016-07-22  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Parameters to Node.replaceChild() / insertBefore() should be mandatory
</span></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicyobjectsrcnoneblocksquicktimepluginreplacementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement-expected.txt (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement-expected.txt                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement-expected.txt        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+CONSOLE MESSAGE: Refused to load yellow.mov because it does not appear in the object-src directive of the Content Security Policy.
+
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicyobjectsrcnoneblocksquicktimepluginreplacementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement.html (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement.html                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement.html        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;object-src 'none'&quot;&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.internals)
+    window.internals.settings.setPluginReplacementEnabled(true);
+
+function done()
+{
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+document.addEventListener(&quot;securitypolicyviolation&quot;, done, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;embed id=&quot;embed&quot; width=&quot;640&quot; height=&quot;480&quot; src=&quot;../../plugins/resources/yellow.mov&quot; qtsrc=&quot;../../plugins/resources/orange.mov&quot;&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicyobjectsrcnoneblocksyoutubepluginreplacementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement-expected.txt (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement-expected.txt                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement-expected.txt        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+CONSOLE MESSAGE: Refused to load https://www.youtube.com/v/UF8uR6Z6KLc because it does not appear in the object-src directive of the Content Security Policy.

</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicyobjectsrcnoneblocksyoutubepluginreplacementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement.html (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement.html                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement.html        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;object-src 'none'&quot;&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.internals)
+    window.internals.settings.setPluginReplacementEnabled(true);
+
+function done()
+{
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+document.addEventListener(&quot;securitypolicyviolation&quot;, done, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;object width=&quot;425&quot; height=&quot;350&quot; classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot;
+    codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot;&gt;
+    &lt;embed width=&quot;425&quot; height=&quot;350&quot; type=&quot;application/x-shockwave-flash&quot; src=&quot;https://www.youtube.com/v/UF8uR6Z6KLc&quot;&gt;
+&lt;/object&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesallowsquicktimepluginreplacementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement-expected.txt (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement-expected.txt                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement-expected.txt        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+ALERT: PASS did load plugin.
+
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesallowsquicktimepluginreplacementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement.html (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement.html                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement.html        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;plugin-types video/quicktime&quot;&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.internals)
+    window.internals.settings.setPluginReplacementEnabled(true);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;embed id=&quot;embed&quot; type=&quot;video/quicktime&quot; width=&quot;640&quot; height=&quot;480&quot; src=&quot;../../plugins/resources/yellow.mov&quot; qtsrc=&quot;../../plugins/resources/orange.mov&quot; postdomevents=true&gt;
+&lt;script&gt;
+document.getElementById(&quot;embed&quot;).addEventListener(&quot;qt_begin&quot;, function () {
+    alert(&quot;PASS did load plugin.&quot;);
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, true);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesallowsyoutubepluginreplacementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement-expected.txt (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement-expected.txt                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement-expected.txt        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+Blocked access to external URL https://www.youtube.com/embed/UF8uR6Z6KLc?showinfo=0
+
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesallowsyoutubepluginreplacementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement.html (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement.html                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement.html        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;plugin-types application/x-shockwave-flash&quot;&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.internals)
+    window.internals.settings.setPluginReplacementEnabled(true);
+
+// Waiting at least 100ms seems to ensure that YouTube plugin replacement has loaded.
+window.setTimeout(function () {
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, 100);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;object width=&quot;425&quot; height=&quot;350&quot; classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot;
+    codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot;&gt;
+    &lt;embed width=&quot;425&quot; height=&quot;350&quot; type=&quot;application/x-shockwave-flash&quot; src=&quot;https://www.youtube.com/v/UF8uR6Z6KLc&quot;&gt;
+&lt;/object&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksquicktimepluginreplacementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-expected.txt (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-expected.txt                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-expected.txt        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+CONSOLE MESSAGE: Refused to load yellow.mov because its MIME type does not appear in the plugin-types directive of the Content Security Policy.
+
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksquicktimepluginreplacementwithoutmimetypeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type-expected.txt (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type-expected.txt                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type-expected.txt        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+CONSOLE MESSAGE: Refused to load yellow.mov because its MIME type does not appear in the plugin-types directive of the Content Security Policy.
+
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksquicktimepluginreplacementwithoutmimetypehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type.html (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type.html                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type.html        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;plugin-types text/html&quot;&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.internals)
+    window.internals.settings.setPluginReplacementEnabled(true);
+
+function done()
+{
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+document.addEventListener(&quot;securitypolicyviolation&quot;, done, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;embed width=&quot;640&quot; height=&quot;480&quot; src=&quot;../../plugins/resources/yellow.mov&quot; qtsrc=&quot;../../plugins/resources/orange.mov&quot;&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksquicktimepluginreplacementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement.html (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement.html                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement.html        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;plugin-types text/html&quot;&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.internals)
+    window.internals.settings.setPluginReplacementEnabled(true);
+
+function done()
+{
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+document.addEventListener(&quot;securitypolicyviolation&quot;, done, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;embed type=&quot;video/quicktime&quot; width=&quot;640&quot; height=&quot;480&quot; src=&quot;../../plugins/resources/yellow.mov&quot; qtsrc=&quot;../../plugins/resources/orange.mov&quot;&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksyoutubepluginreplacementexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-expected.txt (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-expected.txt                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-expected.txt        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+CONSOLE MESSAGE: Refused to load https://www.youtube.com/v/UF8uR6Z6KLc because its MIME type does not appear in the plugin-types directive of the Content Security Policy.

</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksyoutubepluginreplacementwithoutmimetypeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type-expected.txt (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type-expected.txt                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type-expected.txt        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+CONSOLE MESSAGE: Refused to load https://www.youtube.com/v/UF8uR6Z6KLc because its MIME type does not appear in the plugin-types directive of the Content Security Policy.

</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksyoutubepluginreplacementwithoutmimetypehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;plugin-types text/html&quot;&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.internals)
+    window.internals.settings.setPluginReplacementEnabled(true);
+
+function done()
+{
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+document.addEventListener(&quot;securitypolicyviolation&quot;, done, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;object width=&quot;425&quot; height=&quot;350&quot; classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot;
+    codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot;&gt;
+    &lt;embed width=&quot;425&quot; height=&quot;350&quot; src=&quot;https://www.youtube.com/v/UF8uR6Z6KLc&quot;&gt;
+&lt;/object&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssecuritycontentSecurityPolicypluginstypesblocksyoutubepluginreplacementhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html (0 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html                                (rev 0)
+++ trunk/LayoutTests/security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;plugin-types text/html&quot;&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.internals)
+    window.internals.settings.setPluginReplacementEnabled(true);
+
+function done()
+{
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+document.addEventListener(&quot;securitypolicyviolation&quot;, done, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;object width=&quot;425&quot; height=&quot;350&quot; classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot;
+    codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot;&gt;
+    &lt;embed width=&quot;425&quot; height=&quot;350&quot; type=&quot;application/x-shockwave-flash&quot; src=&quot;https://www.youtube.com/v/UF8uR6Z6KLc&quot;&gt;
+&lt;/object&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203610 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-22 19:54:13 UTC (rev 203610)
+++ trunk/Source/WebCore/ChangeLog        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2016-07-22  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        CSP: object-src and plugin-types directives are not respected for plugin replacements
+        https://bugs.webkit.org/show_bug.cgi?id=159761
+        &lt;rdar://problem/27365724&gt;
+
+        Reviewed by Brent Fulgham.
+
+        Apply the Content Security Policy (CSP) object-src and plugin-types directives to content that will
+        load with a plugin replacement.
+
+        Tests: security/contentSecurityPolicy/object-src-none-blocks-quicktime-plugin-replacement.html
+               security/contentSecurityPolicy/object-src-none-blocks-youtube-plugin-replacement.html
+               security/contentSecurityPolicy/plugins-types-allows-quicktime-plugin-replacement.html
+               security/contentSecurityPolicy/plugins-types-allows-youtube-plugin-replacement.html
+               security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement-without-mime-type.html
+               security/contentSecurityPolicy/plugins-types-blocks-quicktime-plugin-replacement.html
+               security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html
+               security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html
+
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::allowedToLoadPluginContent): Added.
+        (WebCore::HTMLPlugInImageElement::requestObject): Only request loading plugin content if we
+        are allowed to load such content.
+        * html/HTMLPlugInImageElement.h:
+        * loader/SubframeLoader.cpp:
+        (WebCore::SubframeLoader::pluginIsLoadable): Removed code to check CSP as we will check CSP
+        earlier in HTMLPlugInImageElement::requestObject().
+        (WebCore::SubframeLoader::requestPlugin): Ditto.
+        (WebCore::SubframeLoader::isPluginContentAllowedByContentSecurityPolicy): Deleted; moved implementation
+        to HTMLPlugInImageElement::allowedToLoadPluginContent().
+        (WebCore::SubframeLoader::requestObject): Deleted.
+        * loader/SubframeLoader.h:
+        * page/csp/ContentSecurityPolicy.cpp:
+        (WebCore::ContentSecurityPolicy::upgradeInsecureRequestIfNeeded): Changed signature from a non-const
+        function to a const function since these functions do not modify |this|.
+        * page/csp/ContentSecurityPolicy.h: 
+
</ins><span class="cx"> 2016-07-22  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Parameters to Node.replaceChild() / insertBefore() should be mandatory
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLPlugInImageElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (203610 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp        2016-07-22 19:54:13 UTC (rev 203610)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Chrome.h&quot;
</span><span class="cx"> #include &quot;ChromeClient.h&quot;
</span><ins>+#include &quot;ContentSecurityPolicy.h&quot;
</ins><span class="cx"> #include &quot;Event.h&quot;
</span><span class="cx"> #include &quot;EventHandler.h&quot;
</span><span class="cx"> #include &quot;EventNames.h&quot;
</span><span class="lines">@@ -770,8 +771,33 @@
</span><span class="cx">     HTMLPlugInElement::defaultEventHandler(event);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool HTMLPlugInImageElement::allowedToLoadPluginContent(const String&amp; url, const String&amp; mimeType) const
+{
+    URL completedURL;
+    if (!url.isEmpty())
+        completedURL = document().completeURL(url);
+
+    ASSERT(document().contentSecurityPolicy());
+    const ContentSecurityPolicy&amp; contentSecurityPolicy = *document().contentSecurityPolicy();
+
+    contentSecurityPolicy.upgradeInsecureRequestIfNeeded(completedURL, ContentSecurityPolicy::InsecureRequestType::Load);
+
+    String declaredMimeType = document().isPluginDocument() &amp;&amp; document().ownerElement() ?
+        document().ownerElement()-&gt;attributeWithoutSynchronization(HTMLNames::typeAttr) : attributeWithoutSynchronization(HTMLNames::typeAttr);
+    bool isInUserAgentShadowTree = this-&gt;isInUserAgentShadowTree();
+    return contentSecurityPolicy.allowObjectFromSource(completedURL, isInUserAgentShadowTree) &amp;&amp; contentSecurityPolicy.allowPluginType(mimeType, declaredMimeType, completedURL, isInUserAgentShadowTree);
+}
+
</ins><span class="cx"> bool HTMLPlugInImageElement::requestObject(const String&amp; url, const String&amp; mimeType, const Vector&lt;String&gt;&amp; paramNames, const Vector&lt;String&gt;&amp; paramValues)
</span><span class="cx"> {
</span><ins>+    if (url.isEmpty() &amp;&amp; mimeType.isEmpty())
+        return false;
+
+    if (!allowedToLoadPluginContent(url, mimeType)) {
+        renderEmbeddedObject()-&gt;setPluginUnavailabilityReason(RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy);
+        return false;
+    }
+
</ins><span class="cx">     if (HTMLPlugInElement::requestObject(url, mimeType, paramNames, paramValues))
</span><span class="cx">         return true;
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLPlugInImageElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (203610 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h        2016-07-22 19:54:13 UTC (rev 203610)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -111,6 +111,8 @@
</span><span class="cx">     bool isPlugInImageElement() const final { return true; }
</span><span class="cx">     bool isRestartedPlugin() const final { return m_isRestartedPlugin; }
</span><span class="cx"> 
</span><ins>+    bool allowedToLoadPluginContent(const String&amp; url, const String&amp; mimeType) const;
+
</ins><span class="cx">     void finishParsingChildren() final;
</span><span class="cx">     void didAddUserAgentShadowRoot(ShadowRoot*) final;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderSubframeLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/SubframeLoader.cpp (203610 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/SubframeLoader.cpp        2016-07-22 19:54:13 UTC (rev 203610)
+++ trunk/Source/WebCore/loader/SubframeLoader.cpp        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -108,22 +108,8 @@
</span><span class="cx">     return shouldUsePlugin(completedURL, mimeType, false, useFallback);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool SubframeLoader::isPluginContentAllowedByContentSecurityPolicy(HTMLPlugInImageElement&amp; pluginElement, const URL&amp; url, const String&amp; mimeType) const
</del><ins>+bool SubframeLoader::pluginIsLoadable(const URL&amp; url, const String&amp; mimeType)
</ins><span class="cx"> {
</span><del>-    if (!document())
-        return true;
-
-    ASSERT(document()-&gt;contentSecurityPolicy());
-    const ContentSecurityPolicy&amp; contentSecurityPolicy = *document()-&gt;contentSecurityPolicy();
-
-    String declaredMimeType = document()-&gt;isPluginDocument() &amp;&amp; document()-&gt;ownerElement() ?
-        document()-&gt;ownerElement()-&gt;attributeWithoutSynchronization(HTMLNames::typeAttr) : pluginElement.attributeWithoutSynchronization(HTMLNames::typeAttr);
-    bool isInUserAgentShadowTree = pluginElement.isInUserAgentShadowTree();
-    return contentSecurityPolicy.allowObjectFromSource(url, isInUserAgentShadowTree) &amp;&amp; contentSecurityPolicy.allowPluginType(mimeType, declaredMimeType, url, isInUserAgentShadowTree);
-}
-
-bool SubframeLoader::pluginIsLoadable(HTMLPlugInImageElement&amp; pluginElement, const URL&amp; url, const String&amp; mimeType)
-{
</del><span class="cx">     if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType)) {
</span><span class="cx">         if (!m_frame.settings().isJavaEnabled())
</span><span class="cx">             return false;
</span><span class="lines">@@ -140,12 +126,6 @@
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (!isPluginContentAllowedByContentSecurityPolicy(pluginElement, url, mimeType)) {
-            RenderEmbeddedObject* renderer = pluginElement.renderEmbeddedObject();
-            renderer-&gt;setPluginUnavailabilityReason(RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy);
-            return false;
-        }
-
</del><span class="cx">         if (!m_frame.loader().mixedContentChecker().canRunInsecureContent(document()-&gt;securityOrigin(), url))
</span><span class="cx">             return false;
</span><span class="cx">     }
</span><span class="lines">@@ -161,7 +141,7 @@
</span><span class="cx">     if ((!allowPlugins() &amp;&amp; !MIMETypeRegistry::isApplicationPluginMIMEType(mimeType)))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (!pluginIsLoadable(ownerElement, url, mimeType))
</del><ins>+    if (!pluginIsLoadable(url, mimeType))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     ASSERT(ownerElement.hasTagName(objectTag) || ownerElement.hasTagName(embedTag));
</span><span class="lines">@@ -242,12 +222,6 @@
</span><span class="cx">         return success;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!isPluginContentAllowedByContentSecurityPolicy(ownerElement, completedURL, mimeType)) {
-        RenderEmbeddedObject* renderer = ownerElement.renderEmbeddedObject();
-        renderer-&gt;setPluginUnavailabilityReason(RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy);
-        return false;
-    }
-
</del><span class="cx">     // If the plug-in element already contains a subframe, loadOrRedirectSubframe will re-use it. Otherwise,
</span><span class="cx">     // it will create a new frame and set it as the RenderWidget's Widget, causing what was previously 
</span><span class="cx">     // in the widget to be torn down.
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderSubframeLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/SubframeLoader.h (203610 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/SubframeLoader.h        2016-07-22 19:54:13 UTC (rev 203610)
+++ trunk/Source/WebCore/loader/SubframeLoader.h        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -77,10 +77,8 @@
</span><span class="cx">     Frame* loadSubframe(HTMLFrameOwnerElement&amp;, const URL&amp;, const String&amp; name, const String&amp; referrer);
</span><span class="cx">     bool loadPlugin(HTMLPlugInImageElement&amp;, const URL&amp;, const String&amp; mimeType, const Vector&lt;String&gt;&amp; paramNames, const Vector&lt;String&gt;&amp; paramValues, bool useFallback);
</span><span class="cx"> 
</span><del>-    bool isPluginContentAllowedByContentSecurityPolicy(HTMLPlugInImageElement&amp;, const URL&amp;, const String&amp; mimeType) const;
-
</del><span class="cx">     bool shouldUsePlugin(const URL&amp;, const String&amp; mimeType, bool hasFallback, bool&amp; useFallback);
</span><del>-    bool pluginIsLoadable(HTMLPlugInImageElement&amp;, const URL&amp;, const String&amp; mimeType);
</del><ins>+    bool pluginIsLoadable(const URL&amp;, const String&amp; mimeType);
</ins><span class="cx"> 
</span><span class="cx">     Document* document() const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepagecspContentSecurityPolicycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp (203610 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp        2016-07-22 19:54:13 UTC (rev 203610)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -829,7 +829,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ContentSecurityPolicy::upgradeInsecureRequestIfNeeded(ResourceRequest&amp; request, InsecureRequestType requestType)
</del><ins>+void ContentSecurityPolicy::upgradeInsecureRequestIfNeeded(ResourceRequest&amp; request, InsecureRequestType requestType) const
</ins><span class="cx"> {
</span><span class="cx">     URL url = request.url();
</span><span class="cx">     upgradeInsecureRequestIfNeeded(url, requestType);
</span><span class="lines">@@ -836,7 +836,7 @@
</span><span class="cx">     request.setURL(url);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ContentSecurityPolicy::upgradeInsecureRequestIfNeeded(URL&amp; url, InsecureRequestType requestType)
</del><ins>+void ContentSecurityPolicy::upgradeInsecureRequestIfNeeded(URL&amp; url, InsecureRequestType requestType) const
</ins><span class="cx"> {
</span><span class="cx">     if (!url.protocolIs(&quot;http&quot;) &amp;&amp; !url.protocolIs(&quot;ws&quot;))
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCorepagecspContentSecurityPolicyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h (203610 => 203611)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h        2016-07-22 19:54:13 UTC (rev 203610)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h        2016-07-22 20:33:11 UTC (rev 203611)
</span><span class="lines">@@ -155,8 +155,8 @@
</span><span class="cx">     void setUpgradeInsecureRequests(bool);
</span><span class="cx">     bool upgradeInsecureRequests() const { return m_upgradeInsecureRequests; }
</span><span class="cx">     enum class InsecureRequestType { Load, FormSubmission, Navigation };
</span><del>-    void upgradeInsecureRequestIfNeeded(ResourceRequest&amp;, InsecureRequestType);
-    void upgradeInsecureRequestIfNeeded(URL&amp;, InsecureRequestType);
</del><ins>+    void upgradeInsecureRequestIfNeeded(ResourceRequest&amp;, InsecureRequestType) const;
+    void upgradeInsecureRequestIfNeeded(URL&amp;, InsecureRequestType) const;
</ins><span class="cx"> 
</span><span class="cx">     HashSet&lt;RefPtr&lt;SecurityOrigin&gt;&gt;&amp;&amp; takeNavigationRequestsToUpgrade();
</span><span class="cx">     void inheritInsecureNavigationRequestsToUpgradeFromOpener(const ContentSecurityPolicy&amp;);
</span></span></pre>
</div>
</div>

</body>
</html>