<!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>[244794] 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/244794">244794</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2019-04-30 12:42:34 -0700 (Tue, 30 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add WKContentRuleList ping resource-type
https://bugs.webkit.org/show_bug.cgi?id=197325
<rdar://problem/49841404>

Reviewed by Geoff Garen.

Source/WebCore:

Tests: http/tests/contentextensions/block-ping-resource-type-ping.html and http/tests/contentextensions/block-ping-resource-type-raw.html

* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
* contentextensions/ContentExtensionsBackend.h:
* loader/PingLoader.cpp:
(WebCore::processContentRuleListsForLoad):
(WebCore::PingLoader::sendPing):
* loader/ResourceLoadInfo.cpp:
(WebCore::ContentExtensions::readResourceType):
(WebCore::ContentExtensions::ResourceLoadInfo::getResourceFlags const):
* loader/ResourceLoadInfo.h:
* page/UserContentProvider.cpp:
(WebCore::UserContentProvider::processContentRuleListsForLoad):
* page/UserContentProvider.h:

LayoutTests:

* http/tests/contentextensions/block-ping-resource-type-raw--expected.txt: Copied from LayoutTests/http/tests/contentextensions/block-ping-expected.txt.
* http/tests/contentextensions/block-ping-resource-type-raw.html: Copied from LayoutTests/http/tests/contentextensions/block-ping.html.
* http/tests/contentextensions/block-ping-resource-type-raw.html.json: Copied from LayoutTests/http/tests/contentextensions/block-ping.html.json.
* http/tests/contentextensions/block-ping-resource-type-ping-expected.txt: Copied from LayoutTests/http/tests/contentextensions/block-ping-expected.txt.
* http/tests/contentextensions/block-ping-resource-type-ping.html: Copied from LayoutTests/http/tests/contentextensions/block-ping.html.
* http/tests/contentextensions/block-ping-resource-type-ping.html.json: Copied from LayoutTests/http/tests/contentextensions/block-ping.html.json.</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="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendh">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h</a></li>
<li><a href="#trunkSourceWebCoreloaderPingLoadercpp">trunk/Source/WebCore/loader/PingLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadInfocpp">trunk/Source/WebCore/loader/ResourceLoadInfo.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadInfoh">trunk/Source/WebCore/loader/ResourceLoadInfo.h</a></li>
<li><a href="#trunkSourceWebCorepageUserContentProvidercpp">trunk/Source/WebCore/page/UserContentProvider.cpp</a></li>
<li><a href="#trunkSourceWebCorepageUserContentProviderh">trunk/Source/WebCore/page/UserContentProvider.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockpingresourcetypepingexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockpingresourcetypepinghtml">trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockpingresourcetypepinghtmljson">trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping.html.json</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockpingresourcetyperawexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockpingresourcetyperawhtml">trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsblockpingresourcetyperawhtmljson">trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw.html.json</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (244793 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-04-30 19:29:46 UTC (rev 244793)
+++ trunk/LayoutTests/ChangeLog 2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2019-04-30  Alex Christensen  <achristensen@webkit.org>
+
+        Add WKContentRuleList ping resource-type
+        https://bugs.webkit.org/show_bug.cgi?id=197325
+        <rdar://problem/49841404>
+
+        Reviewed by Geoff Garen.
+
+        * http/tests/contentextensions/block-ping-resource-type-raw--expected.txt: Copied from LayoutTests/http/tests/contentextensions/block-ping-expected.txt.
+        * http/tests/contentextensions/block-ping-resource-type-raw.html: Copied from LayoutTests/http/tests/contentextensions/block-ping.html.
+        * http/tests/contentextensions/block-ping-resource-type-raw.html.json: Copied from LayoutTests/http/tests/contentextensions/block-ping.html.json.
+        * http/tests/contentextensions/block-ping-resource-type-ping-expected.txt: Copied from LayoutTests/http/tests/contentextensions/block-ping-expected.txt.
+        * http/tests/contentextensions/block-ping-resource-type-ping.html: Copied from LayoutTests/http/tests/contentextensions/block-ping.html.
+        * http/tests/contentextensions/block-ping-resource-type-ping.html.json: Copied from LayoutTests/http/tests/contentextensions/block-ping.html.json.
+
</ins><span class="cx"> 2019-04-30  Shawn Roberts  <sroberts@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Fixing typo in https://trac.webkit.org/changeset/244780/webkit.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockpingresourcetypepingexpectedtxtfromrev244759trunkLayoutTestshttptestscontentextensionsblockpingexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping-expected.txt (from rev 244759, trunk/LayoutTests/http/tests/contentextensions/block-ping-expected.txt) (0 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping-expected.txt   2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+CONSOLE MESSAGE: line 34: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/block-ping-resource-type-ping.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/save-ping.php?test=contentextensions-block-ping-resource-type-ping
+ALERT: PASS: successfully loaded ping url with fetch
+This test follows a link with a ping attribute where the ping URL matches a 'block' rule.  
+
+--------
+Frame: 'link_frame'
+--------
+Link with ping was clicked.
+
+--------
+Frame: 'result_frame'
+--------
+Ping not received - timed out.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockpingresourcetypepinghtmlfromrev244759trunkLayoutTestshttptestscontentextensionsblockpinghtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping.html (from rev 244759, trunk/LayoutTests/http/tests/contentextensions/block-ping.html) (0 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping.html   2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+<head>
+<script>
+if (window.testRunner && window.internals) {
+    testRunner.dumpAsText();
+    testRunner.dumpChildFramesAsText();
+    internals.settings.setHyperlinkAuditingEnabled(true);
+    testRunner.waitUntilDone();
+}
+
+function loadLinkWithPing() {
+    var iframe = document.getElementById("link_frame");
+    var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
+    iframeDoc.write('' +
+        '<img src="resources/delete-ping.php?test=contentextensions-block-ping-resource-type-ping" ' +
+            'onerror="parent.clickOnLinkWithPing();">' +
+        '<a id="a" ' +
+            'href="resources/check-ping.html" ' + // check-ping.html calls showPingResult()
+            'ping="resources/save-ping.php?test=contentextensions-block-ping-resource-type-ping"> ' +
+            'Link with ping' +
+        '</a>'
+        
+    );
+}
+
+function clickOnLinkWithPing() {
+    var iframe = document.getElementById("link_frame");
+    var iframeDoc = iframe.contentDocument;
+    if (window.eventSender) {
+        var a = iframeDoc.getElementById("a");
+        var x = iframe.offsetLeft + a.offsetLeft + 2;
+        var y = iframe.offsetTop + a.offsetTop + 2;
+        eventSender.mouseMoveTo(x, y);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }
+}
+
+function showPingResult() {
+    var iframe = document.getElementById("result_frame");
+    iframe.onload = function() {
+        fetch("resources/save-ping.php?test=contentextensions-block-ping-resource-type-ping").then(()=>{
+            fetch("resources/delete-ping.php?test=contentextensions-block-ping-resource-type-ping").then(()=>{
+                alert("PASS: successfully loaded ping url with fetch");
+                if (window.testRunner) { testRunner.notifyDone(); }
+            })
+        }).catch(error => { alert("FAIL:" + error); if (window.testRunner) { testRunner.notifyDone(); } });
+    }
+    iframe.src = "resources/get-ping-data.php?test=contentextensions-block-ping-resource-type-ping&timeout_ms=1000";
+    // Why timeout_ms=1000:
+    // To pass the test, the ping shouldn't arrive, so we need to
+    // timeout at some point. We don't have to wait too long because
+    // the console message can tell us whether the ping was blocked.
+}
+</script>
+</head>
+
+<body onload="loadLinkWithPing();">
+This test follows a link with a ping attribute where the ping URL matches a 'block' rule.
+<iframe id="link_frame" name="link_frame"><!-- Will contain link with ping --></iframe>
+<iframe id="result_frame" name="result_frame"><!-- Will contain ping data received by server --></iframe>
+</body>
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockpingresourcetypepinghtmljsonfromrev244759trunkLayoutTestshttptestscontentextensionsblockpinghtmljson"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping.html.json (from rev 244759, trunk/LayoutTests/http/tests/contentextensions/block-ping.html.json) (0 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping.html.json                           (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-ping.html.json      2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[
+    {
+        "trigger": {
+            "url-filter": "save-ping.php",
+            "resource-type": ["ping"]
+        },
+        "action": {
+            "type": "block"
+        }
+    }
+]
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockpingresourcetyperawexpectedtxtfromrev244759trunkLayoutTestshttptestscontentextensionsblockpingexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw-expected.txt (from rev 244759, trunk/LayoutTests/http/tests/contentextensions/block-ping-expected.txt) (0 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw-expected.txt                         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw-expected.txt    2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+CONSOLE MESSAGE: line 34: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/block-ping-resource-type-raw.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/save-ping.php?test=contentextensions-block-ping-resource-type-raw
+CONSOLE MESSAGE: line 41: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/block-ping-resource-type-raw.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/save-ping.php?test=contentextensions-block-ping-resource-type-raw
+CONSOLE MESSAGE: line 41: Resource blocked by content blocker
+CONSOLE MESSAGE: line 41: Fetch API cannot load http://127.0.0.1:8000/contentextensions/resources/save-ping.php?test=contentextensions-block-ping-resource-type-raw due to access control checks.
+ALERT: PASS:TypeError: Resource blocked by content blocker
+This test follows a link with a ping attribute where the ping URL matches a 'block' rule.  
+
+--------
+Frame: 'link_frame'
+--------
+Link with ping was clicked.
+
+--------
+Frame: 'result_frame'
+--------
+Ping not received - timed out.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockpingresourcetyperawhtmlfromrev244759trunkLayoutTestshttptestscontentextensionsblockpinghtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw.html (from rev 244759, trunk/LayoutTests/http/tests/contentextensions/block-ping.html) (0 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw.html                         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw.html    2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+<head>
+<script>
+if (window.testRunner && window.internals) {
+    testRunner.dumpAsText();
+    testRunner.dumpChildFramesAsText();
+    internals.settings.setHyperlinkAuditingEnabled(true);
+    testRunner.waitUntilDone();
+}
+
+function loadLinkWithPing() {
+    var iframe = document.getElementById("link_frame");
+    var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
+    iframeDoc.write('' +
+        '<img src="resources/delete-ping.php?test=contentextensions-block-ping-resource-type-raw" ' +
+            'onerror="parent.clickOnLinkWithPing();">' +
+        '<a id="a" ' +
+            'href="resources/check-ping.html" ' + // check-ping.html calls showPingResult()
+            'ping="resources/save-ping.php?test=contentextensions-block-ping-resource-type-raw"> ' +
+            'Link with ping' +
+        '</a>'
+        
+    );
+}
+
+function clickOnLinkWithPing() {
+    var iframe = document.getElementById("link_frame");
+    var iframeDoc = iframe.contentDocument;
+    if (window.eventSender) {
+        var a = iframeDoc.getElementById("a");
+        var x = iframe.offsetLeft + a.offsetLeft + 2;
+        var y = iframe.offsetTop + a.offsetTop + 2;
+        eventSender.mouseMoveTo(x, y);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }
+}
+
+function showPingResult() {
+    var iframe = document.getElementById("result_frame");
+    iframe.onload = function() {
+        fetch("resources/save-ping.php?test=contentextensions-block-ping-resource-type-raw").then(()=>{
+            fetch("resources/delete-ping.php?test=contentextensions-block-ping-resource-type-raw").then(()=>{
+                alert("FAIL: successfully loaded ping url with fetch");
+                if (window.testRunner) { testRunner.notifyDone(); }
+            })
+        }).catch(error => { alert("PASS:" + error); if (window.testRunner) { testRunner.notifyDone(); } });
+    }
+    iframe.src = "resources/get-ping-data.php?test=contentextensions-block-ping-resource-type-raw&timeout_ms=1000";
+    // Why timeout_ms=1000:
+    // To pass the test, the ping shouldn't arrive, so we need to
+    // timeout at some point. We don't have to wait too long because
+    // the console message can tell us whether the ping was blocked.
+}
+</script>
+</head>
+
+<body onload="loadLinkWithPing();">
+This test follows a link with a ping attribute where the ping URL matches a 'block' rule.
+<iframe id="link_frame" name="link_frame"><!-- Will contain link with ping --></iframe>
+<iframe id="result_frame" name="result_frame"><!-- Will contain ping data received by server --></iframe>
+</body>
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsblockpingresourcetyperawhtmljsonfromrev244759trunkLayoutTestshttptestscontentextensionsblockpinghtmljson"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw.html.json (from rev 244759, trunk/LayoutTests/http/tests/contentextensions/block-ping.html.json) (0 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw.html.json                            (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/block-ping-resource-type-raw.html.json       2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[
+    {
+        "trigger": {
+            "url-filter": "save-ping.php",
+            "resource-type": ["raw"]
+        },
+        "action": {
+            "type": "block"
+        }
+    }
+]
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244793 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-04-30 19:29:46 UTC (rev 244793)
+++ trunk/Source/WebCore/ChangeLog      2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2019-04-30  Alex Christensen  <achristensen@webkit.org>
+
+        Add WKContentRuleList ping resource-type
+        https://bugs.webkit.org/show_bug.cgi?id=197325
+        <rdar://problem/49841404>
+
+        Reviewed by Geoff Garen.
+
+        Tests: http/tests/contentextensions/block-ping-resource-type-ping.html and http/tests/contentextensions/block-ping-resource-type-raw.html
+
+        * contentextensions/ContentExtensionsBackend.cpp:
+        (WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
+        * contentextensions/ContentExtensionsBackend.h:
+        * loader/PingLoader.cpp:
+        (WebCore::processContentRuleListsForLoad):
+        (WebCore::PingLoader::sendPing):
+        * loader/ResourceLoadInfo.cpp:
+        (WebCore::ContentExtensions::readResourceType):
+        (WebCore::ContentExtensions::ResourceLoadInfo::getResourceFlags const):
+        * loader/ResourceLoadInfo.h:
+        * page/UserContentProvider.cpp:
+        (WebCore::UserContentProvider::processContentRuleListsForLoad):
+        * page/UserContentProvider.h:
+
</ins><span class="cx"> 2019-04-30  Justin Fan  <justin_fan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [WebGPU] Move 'gpu' API entry point from DOMWindow to Navigator
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (244793 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp      2019-04-30 19:29:46 UTC (rev 244793)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx">     return contentExtension ? contentExtension->globalDisplayNoneStyleSheet() : nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ContentRuleListResults ContentExtensionsBackend::processContentRuleListsForLoad(const URL& url, ResourceType resourceType, DocumentLoader& initiatingDocumentLoader)
</del><ins>+ContentRuleListResults ContentExtensionsBackend::processContentRuleListsForLoad(const URL& url, OptionSet<ResourceType> resourceType, DocumentLoader& initiatingDocumentLoader)
</ins><span class="cx"> {
</span><span class="cx">     if (m_contentExtensions.isEmpty())
</span><span class="cx">         return { };
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h (244793 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2019-04-30 19:29:46 UTC (rev 244793)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h   2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx">     WEBCORE_EXPORT Vector<ActionsFromContentRuleList> actionsForResourceLoad(const ResourceLoadInfo&) const;
</span><span class="cx">     WEBCORE_EXPORT StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const;
</span><span class="cx"> 
</span><del>-    ContentRuleListResults processContentRuleListsForLoad(const URL&, ResourceType, DocumentLoader& initiatingDocumentLoader);
</del><ins>+    ContentRuleListResults processContentRuleListsForLoad(const URL&, OptionSet<ResourceType>, DocumentLoader& initiatingDocumentLoader);
</ins><span class="cx">     WEBCORE_EXPORT ContentRuleListResults processContentRuleListsForPingLoad(const URL&, const URL& mainDocumentURL);
</span><span class="cx"> 
</span><span class="cx">     static const String& displayNoneCSSRule();
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderPingLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/PingLoader.cpp (244793 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/PingLoader.cpp       2019-04-30 19:29:46 UTC (rev 244793)
+++ trunk/Source/WebCore/loader/PingLoader.cpp  2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx"> 
</span><span class="cx"> // Returns true if we should block the load.
</span><del>-static bool processContentRuleListsForLoad(const Frame& frame, ResourceRequest& request, ContentExtensions::ResourceType resourceType)
</del><ins>+static bool processContentRuleListsForLoad(const Frame& frame, ResourceRequest& request, OptionSet<ContentExtensions::ResourceType> resourceType)
</ins><span class="cx"> {
</span><span class="cx">     auto* documentLoader = frame.loader().documentLoader();
</span><span class="cx">     if (!documentLoader)
</span><span class="lines">@@ -119,7 +119,7 @@
</span><span class="cx"> 
</span><span class="cx">     ResourceRequest request(pingURL);
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-    if (processContentRuleListsForLoad(frame, request, ContentExtensions::ResourceType::Raw))
</del><ins>+    if (processContentRuleListsForLoad(frame, request, { ContentExtensions::ResourceType::Raw, ContentExtensions::ResourceType::Ping }))
</ins><span class="cx">         return;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadInfocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadInfo.cpp (244793 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadInfo.cpp 2019-04-30 19:29:46 UTC (rev 244793)
+++ trunk/Source/WebCore/loader/ResourceLoadInfo.cpp    2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -102,6 +102,8 @@
</span><span class="cx">         return static_cast<uint16_t>(ResourceType::Media);
</span><span class="cx">     if (name == "popup")
</span><span class="cx">         return static_cast<uint16_t>(ResourceType::Popup);
</span><ins>+    if (name == "ping")
+        return static_cast<uint16_t>(ResourceType::Ping);
</ins><span class="cx">     return static_cast<uint16_t>(ResourceType::Invalid);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -126,7 +128,7 @@
</span><span class="cx"> {
</span><span class="cx">     ResourceFlags flags = 0;
</span><span class="cx">     ASSERT(type != ResourceType::Invalid);
</span><del>-    flags |= static_cast<ResourceFlags>(type);
</del><ins>+    flags |= type.toRaw();
</ins><span class="cx">     flags |= isThirdParty() ? static_cast<ResourceFlags>(LoadType::ThirdParty) : static_cast<ResourceFlags>(LoadType::FirstParty);
</span><span class="cx">     return flags;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadInfo.h (244793 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadInfo.h   2019-04-30 19:29:46 UTC (rev 244793)
+++ trunk/Source/WebCore/loader/ResourceLoadInfo.h      2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx"> 
</span><span class="cx"> #include "CachedResource.h"
</span><ins>+#include <wtf/OptionSet.h>
</ins><span class="cx"> #include <wtf/URL.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -45,8 +46,10 @@
</span><span class="cx">     Media = 0x0080,
</span><span class="cx">     PlugInStream = 0x0100,
</span><span class="cx">     Popup = 0x0200,
</span><ins>+    // 0x0400 and 0x0800 are used by LoadType.
+    Ping = 0x1000,
</ins><span class="cx"> };
</span><del>-const uint16_t ResourceTypeMask = 0x03FF;
</del><ins>+const uint16_t ResourceTypeMask = 0x13FF;
</ins><span class="cx"> 
</span><span class="cx"> enum class LoadType : uint16_t {
</span><span class="cx">     Invalid = 0x0000,
</span><span class="lines">@@ -55,6 +58,8 @@
</span><span class="cx"> };
</span><span class="cx"> const uint16_t LoadTypeMask = 0x0C00;
</span><span class="cx"> 
</span><ins>+static_assert(!(ResourceTypeMask & LoadTypeMask), "ResourceTypeMask and LoadTypeMask should be mutually exclusive because they are stored in the same uint16_t");
+
</ins><span class="cx"> typedef uint16_t ResourceFlags;
</span><span class="cx"> 
</span><span class="cx"> // The first 32 bits of a uint64_t action are used for the action location.
</span><span class="lines">@@ -74,7 +79,7 @@
</span><span class="cx"> struct ResourceLoadInfo {
</span><span class="cx">     URL resourceURL;
</span><span class="cx">     URL mainDocumentURL;
</span><del>-    ResourceType type;
</del><ins>+    OptionSet<ResourceType> type;
</ins><span class="cx"> 
</span><span class="cx">     bool isThirdParty() const;
</span><span class="cx">     ResourceFlags getResourceFlags() const;
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserContentProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserContentProvider.cpp (244793 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserContentProvider.cpp        2019-04-30 19:29:46 UTC (rev 244793)
+++ trunk/Source/WebCore/page/UserContentProvider.cpp   2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx">     
</span><del>-ContentRuleListResults UserContentProvider::processContentRuleListsForLoad(const URL& url, ContentExtensions::ResourceType resourceType, DocumentLoader& initiatingDocumentLoader)
</del><ins>+ContentRuleListResults UserContentProvider::processContentRuleListsForLoad(const URL& url, OptionSet<ContentExtensions::ResourceType> resourceType, DocumentLoader& initiatingDocumentLoader)
</ins><span class="cx"> {
</span><span class="cx">     if (!contentExtensionsEnabled(initiatingDocumentLoader))
</span><span class="cx">         return { };
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserContentProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserContentProvider.h (244793 => 244794)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserContentProvider.h  2019-04-30 19:29:46 UTC (rev 244793)
+++ trunk/Source/WebCore/page/UserContentProvider.h     2019-04-30 19:42:34 UTC (rev 244794)
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx">     // FIXME: These don't really belong here. They should probably bundled up in the ContentExtensionsBackend
</span><span class="cx">     // which should always exist.
</span><del>-    ContentRuleListResults processContentRuleListsForLoad(const URL&, ContentExtensions::ResourceType, DocumentLoader& initiatingDocumentLoader);
</del><ins>+    ContentRuleListResults processContentRuleListsForLoad(const URL&, OptionSet<ContentExtensions::ResourceType>, DocumentLoader& initiatingDocumentLoader);
</ins><span class="cx">     Vector<ContentExtensions::ActionsFromContentRuleList> actionsForResourceLoad(const ContentExtensions::ResourceLoadInfo&, DocumentLoader& initiatingDocumentLoader);
</span><span class="cx">     WEBCORE_EXPORT void forEachContentExtension(const Function<void(const String&, ContentExtensions::ContentExtension&)>&, DocumentLoader& initiatingDocumentLoader);
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>