<!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>[186597] 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/186597">186597</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2015-07-09 11:36:29 -0700 (Thu, 09 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Content Extensions] Prevent crashes with plugins.
https://bugs.webkit.org/show_bug.cgi?id=146705
rdar://problem/20855444

Reviewed by Brady Eidson.

Source/WebCore:

* loader/NetscapePlugInStreamLoader.cpp:
(WebCore::NetscapePlugInStreamLoader::create):
Call addPlugInStreamLoader in ResourceLoader::willSendRequest to always add blocked loads.
* loader/NetscapePlugInStreamLoader.h:
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::willSendRequest):
Removed unnecessary early returns.
* loader/ResourceLoader.h:
(WebCore::ResourceLoader::isPlugInStreamLoader):

LayoutTests:

* http/tests/contentextensions/plugin-doesnt-crash-expected.txt: Copied from http/tests/plugins/get-url-expected.txt.
* http/tests/contentextensions/plugin-doesnt-crash.html: Copied from http/tests/plugins/get-url.html.
* http/tests/contentextensions/plugin-doesnt-crash.html.json: Added.
* http/tests/contentextensions/resources/load-me-1.txt: Copied from http/tests/plugins/resources/load-me-1.txt.</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="#trunkSourceWebCoreloaderNetscapePlugInStreamLoadercpp">trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderNetscapePlugInStreamLoaderh">trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.h</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadercpp">trunk/Source/WebCore/loader/ResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoaderh">trunk/Source/WebCore/loader/ResourceLoader.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestscontentextensionsplugindoesntcrashexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsplugindoesntcrashhtml">trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsplugindoesntcrashhtmljson">trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash.html.json</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsresourcesloadme1txt">trunk/LayoutTests/http/tests/contentextensions/resources/load-me-1.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (186596 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-07-09 18:34:42 UTC (rev 186596)
+++ trunk/LayoutTests/ChangeLog        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-07-09  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        [Content Extensions] Prevent crashes with plugins.
+        https://bugs.webkit.org/show_bug.cgi?id=146705
+        rdar://problem/20855444
+
+        Reviewed by Brady Eidson.
+
+        * http/tests/contentextensions/plugin-doesnt-crash-expected.txt: Copied from http/tests/plugins/get-url-expected.txt.
+        * http/tests/contentextensions/plugin-doesnt-crash.html: Copied from http/tests/plugins/get-url.html.
+        * http/tests/contentextensions/plugin-doesnt-crash.html.json: Added.
+        * http/tests/contentextensions/resources/load-me-1.txt: Copied from http/tests/plugins/resources/load-me-1.txt.
+
</ins><span class="cx"> 2015-07-09  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Skip canvas/philip/tests/2d.text.draw.fontface.notinpage.html
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsplugindoesntcrashexpectedtxtfromrev186595trunkLayoutTestshttptestspluginsgeturlexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash-expected.txt (from rev 186595, trunk/LayoutTests/http/tests/plugins/get-url-expected.txt) (0 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash-expected.txt        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+CONSOLE MESSAGE: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/plugin-doesnt-crash.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/load-me-1.txt
+This tests that NPN_GetURLNotify works as expected and does not ASSERT intermittently in debug builds. 
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsplugindoesntcrashhtmlfromrev186595trunkLayoutTestshttptestspluginsgeturlhtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash.html (from rev 186595, trunk/LayoutTests/http/tests/plugins/get-url.html) (0 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash.html        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+&lt;html&gt;
+&lt;body&gt;
+This tests that NPN_GetURLNotify works as expected and does not ASSERT intermittently in debug builds.
+&lt;embed name=&quot;plg&quot; type=&quot;application/x-webkit-test-netscape&quot;&gt;&lt;/embed&gt;
+&lt;script&gt;
+    function notify()
+    {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    plg.getURLNotify(&quot;resources/load-me-1.txt&quot;, null, &quot;notify&quot;);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsplugindoesntcrashhtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash.html.json (0 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash.html.json                                (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/plugin-doesnt-crash.html.json        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+[
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;block&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;load-me&quot;
+        }
+    }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsresourcesloadme1txtfromrev186595trunkLayoutTestshttptestspluginsresourcesloadme1txt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/contentextensions/resources/load-me-1.txt (from rev 186595, trunk/LayoutTests/http/tests/plugins/resources/load-me-1.txt) (0 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/resources/load-me-1.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/resources/load-me-1.txt        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+It's a lonely existence being a test file.
+You're welcome.
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (186596 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-07-09 18:34:42 UTC (rev 186596)
+++ trunk/Source/WebCore/ChangeLog        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2015-07-09  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        [Content Extensions] Prevent crashes with plugins.
+        https://bugs.webkit.org/show_bug.cgi?id=146705
+        rdar://problem/20855444
+
+        Reviewed by Brady Eidson.
+
+        * loader/NetscapePlugInStreamLoader.cpp:
+        (WebCore::NetscapePlugInStreamLoader::create):
+        Call addPlugInStreamLoader in ResourceLoader::willSendRequest to always add blocked loads.
+        * loader/NetscapePlugInStreamLoader.h:
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::willSendRequest):
+        Removed unnecessary early returns.
+        * loader/ResourceLoader.h:
+        (WebCore::ResourceLoader::isPlugInStreamLoader):
+
</ins><span class="cx"> 2015-07-09  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Honor CACFLayer content scale factor
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderNetscapePlugInStreamLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp (186596 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp        2015-07-09 18:34:42 UTC (rev 186596)
+++ trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -59,9 +59,7 @@
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;NetscapePlugInStreamLoader&gt; loader(adoptRef(new NetscapePlugInStreamLoader(frame, client)));
</span><span class="cx">     if (!loader-&gt;init(request))
</span><del>-        return 0;
-
-    loader-&gt;documentLoader()-&gt;addPlugInStreamLoader(loader.get());
</del><ins>+        return nullptr;
</ins><span class="cx">     return loader.release();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderNetscapePlugInStreamLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.h (186596 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.h        2015-07-09 18:34:42 UTC (rev 186596)
+++ trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.h        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx">     virtual void didFail(const ResourceError&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     virtual void releaseResources() override;
</span><ins>+    virtual bool isPlugInStreamLoader() override { return true; }
</ins><span class="cx"> 
</span><span class="cx">     NetscapePlugInStreamLoader(Frame*, NetscapePlugInStreamLoaderClient*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (186596 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.cpp        2015-07-09 18:34:42 UTC (rev 186596)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -297,40 +297,32 @@
</span><span class="cx">     ASSERT(m_resourceType != ResourceType::Invalid);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (!frameLoader()) {
-        didFail(cannotShowURLError());
-        return;
</del><ins>+    // We need a resource identifier for all requests, even if FrameLoader is never going to see it (such as with CORS preflight requests).
+    bool createdResourceIdentifier = false;
+    if (!m_identifier) {
+        m_identifier = m_frame-&gt;page()-&gt;progress().createUniqueIdentifier();
+        createdResourceIdentifier = true;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Page* page = frameLoader()-&gt;frame().page();
-    if (!page) {
-        didFail(cannotShowURLError());
-        return;
</del><ins>+#if ENABLE(CONTENT_EXTENSIONS)
+    if (frameLoader()) {
+        Page* page = frameLoader()-&gt;frame().page();
+        if (page &amp;&amp; m_documentLoader) {
+            auto* userContentController = page-&gt;userContentController();
+            if (userContentController)
+                userContentController-&gt;processContentExtensionRulesForLoad(*page, request, m_resourceType, *m_documentLoader);
+        }
</ins><span class="cx">     }
</span><ins>+#endif
+    
+    if (isPlugInStreamLoader())
+        documentLoader()-&gt;addPlugInStreamLoader(this);
</ins><span class="cx"> 
</span><del>-    if (!m_documentLoader) {
-        didFail(cannotShowURLError());
-        return;
-    }
-
-#if ENABLE(CONTENT_EXTENSIONS)
-    auto* userContentController = page-&gt;userContentController();
-    if (userContentController)
-        userContentController-&gt;processContentExtensionRulesForLoad(*page, request, m_resourceType, *m_documentLoader);
-
</del><span class="cx">     if (request.isNull()) {
</span><span class="cx">         didFail(cannotShowURLError());
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-#endif
</del><span class="cx"> 
</span><del>-    // We need a resource identifier for all requests, even if FrameLoader is never going to see it (such as with CORS preflight requests).
-    bool createdResourceIdentifier = false;
-    if (!m_identifier) {
-        m_identifier = m_frame-&gt;page()-&gt;progress().createUniqueIdentifier();
-        createdResourceIdentifier = true;
-    }
-
</del><span class="cx">     if (m_options.sendLoadCallbacks() == SendCallbacks) {
</span><span class="cx">         if (createdResourceIdentifier)
</span><span class="cx">             frameLoader()-&gt;notifier().assignIdentifierToInitialRequest(m_identifier, documentLoader(), request);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.h (186596 => 186597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.h        2015-07-09 18:34:42 UTC (rev 186596)
+++ trunk/Source/WebCore/loader/ResourceLoader.h        2015-07-09 18:36:29 UTC (rev 186597)
</span><span class="lines">@@ -180,6 +180,7 @@
</span><span class="cx">     virtual void didCancel(const ResourceError&amp;) = 0;
</span><span class="cx"> 
</span><span class="cx">     void addDataOrBuffer(const char*, unsigned, SharedBuffer*, DataPayloadType);
</span><ins>+    virtual bool isPlugInStreamLoader() { return false; }
</ins><span class="cx"> 
</span><span class="cx">     // ResourceHandleClient
</span><span class="cx">     virtual void willSendRequest(ResourceHandle*, ResourceRequest&amp;, const ResourceResponse&amp; redirectResponse) override;
</span></span></pre>
</div>
</div>

</body>
</html>