<!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>[242941] 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/242941">242941</a></dd>
<dt>Author</dt> <dd>drousso@apple.com</dd>
<dt>Date</dt> <dd>2019-03-14 03:13:57 -0700 (Thu, 14 Mar 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Audit: provide a way to get the contents of resources
https://bugs.webkit.org/show_bug.cgi?id=195266
<rdar://problem/48550911>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeAsyncCall):
Drive-by: fix missing `else`.

Source/WebCore:

Test: inspector/audit/run-resources.html

* inspector/InspectorAuditResourcesObject.idl: Added.
* inspector/InspectorAuditResourcesObject.h: Added.
(WebCore::InspectorAuditResourcesObject::create):
(WebCore::InspectorAuditResourcesObject::Resource):
(WebCore::InspectorAuditResourcesObject::ResourceContent):
(WebCore::InspectorAuditResourcesObject::InspectorAuditCachedResourceClient):
(WebCore::InspectorAuditResourcesObject::InspectorAuditCachedFontClient):
(WebCore::InspectorAuditResourcesObject::InspectorAuditCachedImageClient):
(WebCore::InspectorAuditResourcesObject::InspectorAuditCachedRawResourceClient):
(WebCore::InspectorAuditResourcesObject::InspectorAuditCachedStyleSheetClient):
(WebCore::InspectorAuditResourcesObject::InspectorAuditCachedSVGDocumentClient):
* inspector/InspectorAuditResourcesObject.cpp: Added.
(WebCore::InspectorAuditResourcesObject::InspectorAuditResourcesObject):
(WebCore::InspectorAuditResourcesObject::getResources):
(WebCore::InspectorAuditResourcesObject::getResourceContent):
(WebCore::InspectorAuditResourcesObject::clientForResource):

* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::cachedResourcesForFrame): Added.
(WebCore::allResourcesURLsForFrame):
Moved a file static function to be a class static function so it can be used elsewhere.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

LayoutTests:

* inspector/audit/resources/sample-resource.css: Added.
* inspector/audit/resources/sample-resource.js: Added.
* inspector/audit/run-resources.html: Added.
* inspector/audit/run-resources-expected.txt: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorInjectedScriptBasecpp">trunk/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesinputxcfilelist">trunk/Source/WebCore/DerivedSources-input.xcfilelist</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesoutputxcfilelist">trunk/Source/WebCore/DerivedSources-output.xcfilelist</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebCoreSourcestxt">trunk/Source/WebCore/Sources.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreinspectoragentsInspectorPageAgentcpp">trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectoragentsInspectorPageAgenth">trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h</a></li>
<li><a href="#trunkSourceWebCoreinspectoragentspagePageAuditAgentcpp">trunk/Source/WebCore/inspector/agents/page/PageAuditAgent.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectorauditresourcessampleresourcecss">trunk/LayoutTests/inspector/audit/resources/sample-resource.css</a></li>
<li><a href="#trunkLayoutTestsinspectorauditresourcessampleresourcejs">trunk/LayoutTests/inspector/audit/resources/sample-resource.js</a></li>
<li><a href="#trunkLayoutTestsinspectorauditrunresourcesexpectedtxt">trunk/LayoutTests/inspector/audit/run-resources-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorauditrunresourceshtml">trunk/LayoutTests/inspector/audit/run-resources.html</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorAuditResourcesObjectcpp">trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorAuditResourcesObjecth">trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorAuditResourcesObjectidl">trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/LayoutTests/ChangeLog 2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2019-03-14  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><ins>+        Web Inspector: Audit: provide a way to get the contents of resources
+        https://bugs.webkit.org/show_bug.cgi?id=195266
+        <rdar://problem/48550911>
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/audit/resources/sample-resource.css: Added.
+        * inspector/audit/resources/sample-resource.js: Added.
+        * inspector/audit/run-resources.html: Added.
+        * inspector/audit/run-resources-expected.txt: Added.
+
+2019-03-14  Devin Rousso  <drousso@apple.com>
+
</ins><span class="cx">         Web Inspector: Console: getEventListeners should work for any EventTarget
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=195713
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorauditresourcessampleresourcecss"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/audit/resources/sample-resource.css (0 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/audit/resources/sample-resource.css                          (rev 0)
+++ trunk/LayoutTests/inspector/audit/resources/sample-resource.css     2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+/* TEST CSS */
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorauditresourcessampleresourcejs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/audit/resources/sample-resource.js (0 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/audit/resources/sample-resource.js                           (rev 0)
+++ trunk/LayoutTests/inspector/audit/resources/sample-resource.js      2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+/* TEST JS */
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorauditrunresourcesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/audit/run-resources-expected.txt (0 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/audit/run-resources-expected.txt                             (rev 0)
+++ trunk/LayoutTests/inspector/audit/run-resources-expected.txt        2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+
+Tests for the injected WebInspectorAudit.Resources functions.
+
+
+== Running test suite: Audit.run.Resources
+-- Running test case: Audit.run.Resources.getResources
+Audit setup...
+Audit run `WebInspectorAudit.Resources.getResources()`...
+Found dataURL image.
+PASS: dataURL image should have the expected content.
+PASS: dataURL image should be base64 encoded.
+Found sample-resource.css.
+PASS: sample-resource.css should have the expected content.
+PASS: sample-resource.css should not be base64 encoded.
+Found sample-resource.js.
+PASS: sample-resource.js should have the expected content.
+PASS: sample-resource.js should not be base64 encoded.
+Audit teardown...
+
+-- Running test case: Audit.run.Resources.getResourceContent.InvalidId
+Audit setup...
+Audit run `WebInspectorAudit.Resources.getResourceContent(-1)`...
+PASS: Should throw an exception.
+NotFoundError: Unknown identifier -1
+Audit teardown...
+
+-- Running test case: Audit.run.Resources.InvalidCopiedFunctionCall
+Audit setup...
+Copying WebInspectorAudit to window...
+Audit teardown...
+Testing copied getResources...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+Testing copied getResourceContent...
+PASS: Should produce an exception.
+Error: NotAllowedError: Cannot be called outside of a Web Inspector Audit
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorauditrunresourceshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/audit/run-resources.html (0 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/audit/run-resources.html                             (rev 0)
+++ trunk/LayoutTests/inspector/audit/run-resources.html        2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -0,0 +1,122 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script src="resources/audit-utilities.js"></script>
+<script src="resources/sample-resource.js"></script>
+<link rel="stylesheet" href="resources/sample-resource.css">
+<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAAXNSR0IArs4c6QAAABNJREFUCB1j/M/AAEQMDEwgAgQAHxcCAmtAm/sAAAAASUVORK5CYII=">
+<script>
+function test()
+{
+    InspectorTest.debug();
+
+    let suite = InspectorTest.Audit.createSuite("Audit.run.Resources");
+
+    function evaluateStringForTest(func, args) {
+        return `WebInspectorAudit.Resources.${func}(${Array.isArray(args) ? args.map(JSON.stringify).join(", ") : ""})`;
+    }
+
+    const tests = [
+        { name: "Audit.run.Resources.getResources", func: "getResources" },
+        { name: "Audit.run.Resources.getResourceContent.InvalidId", func: "getResourceContent", args: [-1], shouldError: true, },
+    ];
+
+    for (let {name, func, args, shouldError} of tests) {
+        suite.addTestCase({
+            name,
+            async test() {
+                async function getContentForResource(resource) {
+                    let {result, wasThrown} = await AuditAgent.run(`function() { return JSON.stringify(${evaluateStringForTest("getResourceContent", [resource.id])}); }`);
+                    InspectorTest.assert(!wasThrown, "Should not throw an exception");
+                    return JSON.parse(result.value);
+                }
+
+                let functionString = evaluateStringForTest(func, args);
+
+                await InspectorTest.Audit.setupAudit();
+
+                InspectorTest.log(`Audit run \`${functionString}\`...`);
+                let {result, wasThrown} = await AuditAgent.run(`function() { return JSON.stringify(${functionString}); }`);
+
+                if (shouldError)
+                    InspectorTest.expectThat(wasThrown, "Should throw an exception.");
+                else
+                    InspectorTest.assert(!wasThrown, "Should not throw an exception.");
+
+                if (!wasThrown) {
+                    let resources = JSON.parse(result.value);
+
+                    resources.sort((a, b) => a.url.extendedLocaleCompare(b.url));
+
+                    for (let resource of resources) {
+                        InspectorTest.assert(resource.id, `All resources should have "id".`);
+                        InspectorTest.assert(resource.url, `All resources should have "url".`);
+                        InspectorTest.assert(resource.mimeType, `All resources should have "mimeType".`);
+
+                        if (resource.url.endsWith("sample-resource.js")) {
+                            InspectorTest.log("Found sample-resource.js.");
+                            InspectorTest.assert(resource.mimeType === "text/javascript", "sample-resource.js should have a text/javascript MIME type.");
+
+                            let content = await getContentForResource(resource);
+                            InspectorTest.expectEqual(content.data, "/* TEST JS */", "sample-resource.js should have the expected content.");
+                            InspectorTest.expectFalse(content.base64Encoded, "sample-resource.js should not be base64 encoded.");
+                        }
+
+                        if (resource.url.endsWith("sample-resource.css")) {
+                            InspectorTest.log("Found sample-resource.css.");
+                            InspectorTest.assert(resource.mimeType === "text/css", "sample-resource.css should have a text/css MIME type.");
+
+                            let content = await getContentForResource(resource);
+                            InspectorTest.expectEqual(content.data, "/* TEST CSS */", "sample-resource.css should have the expected content.");
+                            InspectorTest.expectFalse(content.base64Encoded, "sample-resource.css should not be base64 encoded.");
+                        }
+
+                        if (resource.url.startsWith("data:image/png;base64")) {
+                            InspectorTest.log("Found dataURL image.");
+                            InspectorTest.assert(resource.mimeType === "image/png", "dataURL image should have a image/png MIME type.");
+
+                            let content = await getContentForResource(resource);
+                            InspectorTest.expectEqual(content.data, "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAAXNSR0IArs4c6QAAABNJREFUCB1j/M/AAEQMDEwgAgQAHxcCAmtAm/sAAAAASUVORK5CYII=", "dataURL image should have the expected content.");
+                            InspectorTest.expectThat(content.base64Encoded, "dataURL image should be base64 encoded.");
+                        }
+                    }
+                } else
+                    InspectorTest.log(result.description);
+
+                await InspectorTest.Audit.teardownAudit();
+            },
+        });
+    }
+
+    suite.addTestCase({
+        name: "Audit.run.Resources.InvalidCopiedFunctionCall",
+        description: "Check that WebInspectorAudit.Resources functions throw an error when called outside of an audit.",
+        async test() {
+            let functions = new Map;
+            for (let test of tests)
+                functions.set(test.func, test);
+
+            await InspectorTest.Audit.setupAudit();
+            InspectorTest.log(`Copying WebInspectorAudit to window...`);
+            let {wasThrown} = await AuditAgent.run(`function() { window.CopiedWebInspectorAudit = WebInspectorAudit; }`);
+            InspectorTest.assert(!wasThrown, "Should not throw an exception.");
+            await InspectorTest.Audit.teardownAudit();
+
+            for (let {func, args} of functions.values()) {
+                InspectorTest.log(`Testing copied ${func}...`);
+                await InspectorTest.expectException(async function() {
+                    await InspectorTest.evaluateInPage("window.Copied" + evaluateStringForTest(func, args));
+                });
+            }
+        },
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+    <p>Tests for the injected WebInspectorAudit.Resources functions.</p>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog    2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/JavaScriptCore/ChangeLog       2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -1,5 +1,17 @@
</span><span class="cx"> 2019-03-14  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><ins>+        Web Inspector: Audit: provide a way to get the contents of resources
+        https://bugs.webkit.org/show_bug.cgi?id=195266
+        <rdar://problem/48550911>
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/InjectedScriptBase.cpp:
+        (Inspector::InjectedScriptBase::makeAsyncCall):
+        Drive-by: fix missing `else`.
+
+2019-03-14  Devin Rousso  <drousso@apple.com>
+
</ins><span class="cx">         Web Inspector: Styles: `::-webkit-scrollbar*` rules aren't shown
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=195123
</span><span class="cx">         <rdar://problem/48450148>
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorInjectedScriptBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp     2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp        2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -119,7 +119,7 @@
</span><span class="cx">         jsFunction = JSC::JSNativeStdFunction::create(vm, scriptState->lexicalGlobalObject(), 1, String(), [&, callback = WTFMove(callback)] (JSC::ExecState* exec) {
</span><span class="cx">             if (!exec)
</span><span class="cx">                 checkAsyncCallResult(JSON::Value::create("Exception while making a call."), callback);
</span><del>-            if (auto resultJSONValue = toInspectorValue(*exec, exec->argument(0)))
</del><ins>+            else if (auto resultJSONValue = toInspectorValue(*exec, exec->argument(0)))
</ins><span class="cx">                 checkAsyncCallResult(resultJSONValue, callback);
</span><span class="cx">             else
</span><span class="cx">                 checkAsyncCallResult(JSON::Value::create(makeString("Object has too long reference chain (must not be longer than ", JSON::Value::maxDepth, ')')), callback);
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt      2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/CMakeLists.txt 2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -902,6 +902,7 @@
</span><span class="cx">     inspector/CommandLineAPIHost.idl
</span><span class="cx">     inspector/InspectorAuditAccessibilityObject.idl
</span><span class="cx">     inspector/InspectorAuditDOMObject.idl
</span><ins>+    inspector/InspectorAuditResourcesObject.idl
</ins><span class="cx">     inspector/InspectorFrontendHost.idl
</span><span class="cx"> 
</span><span class="cx">     loader/appcache/DOMApplicationCache.idl
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/ChangeLog      2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -1,5 +1,45 @@
</span><span class="cx"> 2019-03-14  Devin Rousso  <drousso@apple.com>
</span><span class="cx"> 
</span><ins>+        Web Inspector: Audit: provide a way to get the contents of resources
+        https://bugs.webkit.org/show_bug.cgi?id=195266
+        <rdar://problem/48550911>
+
+        Reviewed by Joseph Pecoraro.
+
+        Test: inspector/audit/run-resources.html
+
+        * inspector/InspectorAuditResourcesObject.idl: Added.
+        * inspector/InspectorAuditResourcesObject.h: Added.
+        (WebCore::InspectorAuditResourcesObject::create):
+        (WebCore::InspectorAuditResourcesObject::Resource):
+        (WebCore::InspectorAuditResourcesObject::ResourceContent):
+        (WebCore::InspectorAuditResourcesObject::InspectorAuditCachedResourceClient):
+        (WebCore::InspectorAuditResourcesObject::InspectorAuditCachedFontClient):
+        (WebCore::InspectorAuditResourcesObject::InspectorAuditCachedImageClient):
+        (WebCore::InspectorAuditResourcesObject::InspectorAuditCachedRawResourceClient):
+        (WebCore::InspectorAuditResourcesObject::InspectorAuditCachedStyleSheetClient):
+        (WebCore::InspectorAuditResourcesObject::InspectorAuditCachedSVGDocumentClient):
+        * inspector/InspectorAuditResourcesObject.cpp: Added.
+        (WebCore::InspectorAuditResourcesObject::InspectorAuditResourcesObject):
+        (WebCore::InspectorAuditResourcesObject::getResources):
+        (WebCore::InspectorAuditResourcesObject::getResourceContent):
+        (WebCore::InspectorAuditResourcesObject::clientForResource):
+
+        * inspector/agents/InspectorPageAgent.h:
+        * inspector/agents/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::cachedResourcesForFrame): Added.
+        (WebCore::allResourcesURLsForFrame):
+        Moved a file static function to be a class static function so it can be used elsewhere.
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
+2019-03-14  Devin Rousso  <drousso@apple.com>
+
</ins><span class="cx">         Web Inspector: Console: getEventListeners should work for any EventTarget
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=195713
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesinputxcfilelist"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources-input.xcfilelist     2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist        2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -872,6 +872,7 @@
</span><span class="cx"> $(PROJECT_DIR)/inspector/CommandLineAPIModuleSource.js
</span><span class="cx"> $(PROJECT_DIR)/inspector/InspectorAuditAccessibilityObject.idl
</span><span class="cx"> $(PROJECT_DIR)/inspector/InspectorAuditDOMObject.idl
</span><ins>+$(PROJECT_DIR)/inspector/InspectorAuditResourcesObject.idl
</ins><span class="cx"> $(PROJECT_DIR)/inspector/InspectorFrontendHost.idl
</span><span class="cx"> $(PROJECT_DIR)/loader/appcache/DOMApplicationCache.idl
</span><span class="cx"> $(PROJECT_DIR)/make-hash-tools.pl
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesoutputxcfilelist"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources-output.xcfilelist    2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist       2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -867,6 +867,8 @@
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorAuditAccessibilityObject.h
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorAuditDOMObject.cpp
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorAuditDOMObject.h
</span><ins>+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorAuditResourcesObject.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorAuditResourcesObject.h
</ins><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorFrontendHost.cpp
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInspectorFrontendHost.h
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInternalSettings.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make 2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/DerivedSources.make    2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -852,6 +852,7 @@
</span><span class="cx">     $(WebCore)/inspector/CommandLineAPIHost.idl \
</span><span class="cx">     $(WebCore)/inspector/InspectorAuditAccessibilityObject.idl \
</span><span class="cx">     $(WebCore)/inspector/InspectorAuditDOMObject.idl \
</span><ins>+    $(WebCore)/inspector/InspectorAuditResourcesObject.idl \
</ins><span class="cx">     $(WebCore)/inspector/InspectorFrontendHost.idl \
</span><span class="cx">     $(WebCore)/loader/appcache/DOMApplicationCache.idl \
</span><span class="cx">     $(WebCore)/page/BarProp.idl \
</span></span></pre></div>
<a id="trunkSourceWebCoreSourcestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Sources.txt (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Sources.txt 2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/Sources.txt    2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -1276,6 +1276,7 @@
</span><span class="cx"> inspector/DOMPatchSupport.cpp
</span><span class="cx"> inspector/InspectorAuditAccessibilityObject.cpp
</span><span class="cx"> inspector/InspectorAuditDOMObject.cpp
</span><ins>+inspector/InspectorAuditResourcesObject.cpp
</ins><span class="cx"> inspector/InspectorCanvas.cpp
</span><span class="cx"> inspector/InspectorClient.cpp
</span><span class="cx"> inspector/InspectorController.cpp
</span><span class="lines">@@ -2915,6 +2916,7 @@
</span><span class="cx"> JSInputEvent.cpp
</span><span class="cx"> JSInspectorAuditAccessibilityObject.cpp
</span><span class="cx"> JSInspectorAuditDOMObject.cpp
</span><ins>+JSInspectorAuditResourcesObject.cpp
</ins><span class="cx"> JSInspectorFrontendHost.cpp
</span><span class="cx"> JSIntersectionObserver.cpp
</span><span class="cx"> JSIntersectionObserverCallback.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -2608,6 +2608,8 @@
</span><span class="cx">          9001774012E0347800648462 /* OESStandardDerivatives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9001773D12E0347800648462 /* OESStandardDerivatives.cpp */; };
</span><span class="cx">          9001774112E0347800648462 /* OESStandardDerivatives.h in Headers */ = {isa = PBXBuildFile; fileRef = 9001773E12E0347800648462 /* OESStandardDerivatives.h */; };
</span><span class="cx">          9001788112E0370700648462 /* JSOESStandardDerivatives.h in Headers */ = {isa = PBXBuildFile; fileRef = 9001787F12E0370700648462 /* JSOESStandardDerivatives.h */; };
</span><ins>+               9109E9C8222CABCA00BB6264 /* InspectorAuditResourcesObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 9109E9C5222CABC800BB6264 /* InspectorAuditResourcesObject.h */; };
+               9109E9C8222CABCA00BB6265 /* JSInspectorAuditResourcesObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 9109E9C5222CABC800BB6265 /* JSInspectorAuditResourcesObject.h */; };
</ins><span class="cx">           91278D5E21DEDAD600B57184 /* PageAuditAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 91278D5C21DEDAD500B57184 /* PageAuditAgent.h */; };
</span><span class="cx">          91278D6221DEDAF000B57184 /* WorkerAuditAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 91278D6021DEDAF000B57184 /* WorkerAuditAgent.h */; };
</span><span class="cx">          9175CE5C21E281ED00DF2C27 /* InspectorAuditDOMObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 9175CE5821E281EC00DF2C27 /* InspectorAuditDOMObject.h */; };
</span><span class="lines">@@ -10466,6 +10468,10 @@
</span><span class="cx">          9001773F12E0347800648462 /* OESStandardDerivatives.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OESStandardDerivatives.idl; sourceTree = "<group>"; };
</span><span class="cx">          9001787E12E0370700648462 /* JSOESStandardDerivatives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESStandardDerivatives.cpp; sourceTree = "<group>"; };
</span><span class="cx">          9001787F12E0370700648462 /* JSOESStandardDerivatives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESStandardDerivatives.h; sourceTree = "<group>"; };
</span><ins>+               9109E9C5222CABC800BB6264 /* InspectorAuditResourcesObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorAuditResourcesObject.h; sourceTree = "<group>"; };
+               9109E9C5222CABC800BB6265 /* JSInspectorAuditResourcesObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInspectorAuditResourcesObject.h; sourceTree = "<group>"; };
+               9109E9C7222CABC900BB6264 /* InspectorAuditResourcesObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorAuditResourcesObject.cpp; sourceTree = "<group>"; };
+               9109E9C7222CABC900BB6265 /* JSInspectorAuditResourcesObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInspectorAuditResourcesObject.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           91278D5A21DEDAD500B57184 /* PageAuditAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageAuditAgent.cpp; sourceTree = "<group>"; };
</span><span class="cx">          91278D5C21DEDAD500B57184 /* PageAuditAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageAuditAgent.h; sourceTree = "<group>"; };
</span><span class="cx">          91278D5F21DEDAEF00B57184 /* WorkerAuditAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerAuditAgent.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -17061,6 +17067,8 @@
</span><span class="cx">                          9175CE5A21E281ED00DF2C28 /* JSInspectorAuditAccessibilityObject.h */,
</span><span class="cx">                          9175CE5721E281EB00DF2C28 /* JSInspectorAuditDOMObject.cpp */,
</span><span class="cx">                          9175CE5821E281EC00DF2C28 /* JSInspectorAuditDOMObject.h */,
</span><ins>+                               9109E9C7222CABC900BB6265 /* JSInspectorAuditResourcesObject.cpp */,
+                               9109E9C5222CABC800BB6265 /* JSInspectorAuditResourcesObject.h */,
</ins><span class="cx">                           7A0E771C10C00DB100A0276E /* JSInspectorFrontendHost.cpp */,
</span><span class="cx">                          7A0E771D10C00DB100A0276E /* JSInspectorFrontendHost.h */,
</span><span class="cx">                  );
</span><span class="lines">@@ -17085,6 +17093,8 @@
</span><span class="cx">                          9175CE5A21E281ED00DF2C27 /* InspectorAuditAccessibilityObject.h */,
</span><span class="cx">                          9175CE5721E281EB00DF2C27 /* InspectorAuditDOMObject.cpp */,
</span><span class="cx">                          9175CE5821E281EC00DF2C27 /* InspectorAuditDOMObject.h */,
</span><ins>+                               9109E9C7222CABC900BB6264 /* InspectorAuditResourcesObject.cpp */,
+                               9109E9C5222CABC800BB6264 /* InspectorAuditResourcesObject.h */,
</ins><span class="cx">                           6A22E8721F1042C400F546C3 /* InspectorCanvas.cpp */,
</span><span class="cx">                          6A22E86F1F10418600F546C3 /* InspectorCanvas.h */,
</span><span class="cx">                          7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */,
</span><span class="lines">@@ -29771,6 +29781,7 @@
</span><span class="cx">                          A5B81CA71FAA44620037D1E6 /* InspectorApplicationCacheAgent.h in Headers */,
</span><span class="cx">                          9175CE5E21E281ED00DF2C27 /* InspectorAuditAccessibilityObject.h in Headers */,
</span><span class="cx">                          9175CE5C21E281ED00DF2C27 /* InspectorAuditDOMObject.h in Headers */,
</span><ins>+                               9109E9C8222CABCA00BB6264 /* InspectorAuditResourcesObject.h in Headers */,
</ins><span class="cx">                           6A22E8701F10418600F546C3 /* InspectorCanvas.h in Headers */,
</span><span class="cx">                          A5B81CA81FAA44620037D1E6 /* InspectorCanvasAgent.h in Headers */,
</span><span class="cx">                          1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */,
</span><span class="lines">@@ -30206,6 +30217,7 @@
</span><span class="cx">                          A86629D309DA2B48009633A6 /* JSInputEvent.h in Headers */,
</span><span class="cx">                          9175CE5E21E281ED00DF2C28 /* JSInspectorAuditAccessibilityObject.h in Headers */,
</span><span class="cx">                          9175CE5C21E281ED00DF2C28 /* JSInspectorAuditDOMObject.h in Headers */,
</span><ins>+                               9109E9C8222CABCA00BB6265 /* JSInspectorAuditResourcesObject.h in Headers */,
</ins><span class="cx">                           7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */,
</span><span class="cx">                          0F4710E61DB700C7002DCEC3 /* JSIntersectionObserver.h in Headers */,
</span><span class="cx">                          0F8B45761DC41DBA00443C3F /* JSIntersectionObserverCallback.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorAuditResourcesObjectcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.cpp (0 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.cpp                         (rev 0)
+++ trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.cpp    2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -0,0 +1,137 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InspectorAuditResourcesObject.h"
+
+#include "CachedCSSStyleSheet.h"
+#include "CachedFont.h"
+#include "CachedImage.h"
+#include "CachedRawResource.h"
+#include "CachedResource.h"
+#include "CachedSVGDocument.h"
+#include "Document.h"
+#include "InspectorPageAgent.h"
+#include <wtf/HashMap.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+using namespace Inspector;
+
+#define ERROR_IF_NO_ACTIVE_AUDIT() \
+    if (!m_auditAgent.hasActiveAudit()) \
+        return Exception { NotAllowedError, "Cannot be called outside of a Web Inspector Audit"_s };
+
+InspectorAuditResourcesObject::InspectorAuditResourcesObject(InspectorAuditAgent& auditAgent)
+    : m_auditAgent(auditAgent)
+{
+}
+
+InspectorAuditResourcesObject::~InspectorAuditResourcesObject()
+{
+    for (auto* cachedResource : m_resources.values())
+        cachedResource->removeClient(clientForResource(*cachedResource));
+}
+
+ExceptionOr<Vector<InspectorAuditResourcesObject::Resource>> InspectorAuditResourcesObject::getResources(Document& document)
+{
+    ERROR_IF_NO_ACTIVE_AUDIT();
+
+    Vector<Resource> resources;
+
+    auto* frame = document.frame();
+    if (!frame)
+        return Exception { NotAllowedError, "Cannot be called with a detached document"_s };
+
+    for (auto* cachedResource : InspectorPageAgent::cachedResourcesForFrame(frame)) {
+        Resource resource;
+        resource.url = cachedResource->url();
+        resource.mimeType = cachedResource->mimeType();
+
+        bool exists = false;
+        for (const auto& entry : m_resources) {
+            if (entry.value == cachedResource) {
+                resource.id = entry.key;
+                exists = true;
+                break;
+            }
+        }
+        if (!exists) {
+            cachedResource->addClient(clientForResource(*cachedResource));
+
+            resource.id = String::number(m_resources.size() + 1);
+            m_resources.add(resource.id, cachedResource);
+        }
+
+        resources.append(WTFMove(resource));
+    }
+
+    return resources;
+}
+
+ExceptionOr<InspectorAuditResourcesObject::ResourceContent> InspectorAuditResourcesObject::getResourceContent(Document& document, const String& id)
+{
+    ERROR_IF_NO_ACTIVE_AUDIT();
+
+    auto* frame = document.frame();
+    if (!frame)
+        return Exception { NotAllowedError, "Cannot be called with a detached document"_s };
+
+    auto* cachedResource = m_resources.get(id);
+    if (!cachedResource)
+        return Exception { NotFoundError, makeString("Unknown identifier "_s, id) };
+
+    ErrorString errorString;
+    ResourceContent resourceContent;
+    InspectorPageAgent::resourceContent(errorString, frame, cachedResource->url(), &resourceContent.data, &resourceContent.base64Encoded);
+    if (!errorString.isEmpty())
+        return Exception { NotFoundError, errorString };
+
+    return resourceContent;
+}
+
+CachedResourceClient& InspectorAuditResourcesObject::clientForResource(const CachedResource& cachedResource)
+{
+    if (is<CachedCSSStyleSheet>(cachedResource))
+        return m_cachedStyleSheetClient;
+
+    if (is<CachedFont>(cachedResource))
+        return m_cachedFontClient;
+
+    if (is<CachedImage>(cachedResource))
+        return m_cachedImageClient;
+
+    if (is<CachedRawResource>(cachedResource))
+        return m_cachedRawResourceClient;
+
+    if (is<CachedSVGDocument>(cachedResource))
+        return m_cachedSVGDocumentClient;
+
+    return m_cachedResourceClient;
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorAuditResourcesObjecth"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.h (0 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.h                           (rev 0)
+++ trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.h      2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -0,0 +1,96 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CachedFontClient.h"
+#include "CachedImageClient.h"
+#include "CachedRawResourceClient.h"
+#include "CachedResourceClient.h"
+#include "CachedSVGDocumentClient.h"
+#include "CachedStyleSheetClient.h"
+#include "ExceptionOr.h"
+#include <JavaScriptCore/InspectorAuditAgent.h>
+#include <wtf/Forward.h>
+#include <wtf/Ref.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class CachedResource;
+class Document;
+
+class InspectorAuditResourcesObject : public RefCounted<InspectorAuditResourcesObject> {
+public:
+    static Ref<InspectorAuditResourcesObject> create(Inspector::InspectorAuditAgent& auditAgent)
+    {
+        return adoptRef(*new InspectorAuditResourcesObject(auditAgent));
+    }
+
+    ~InspectorAuditResourcesObject();
+
+    struct Resource {
+        String id;
+        String url;
+        String mimeType;
+    };
+
+    struct ResourceContent {
+        String data;
+        bool base64Encoded;
+    };
+
+    ExceptionOr<Vector<Resource>> getResources(Document&);
+    ExceptionOr<ResourceContent> getResourceContent(Document&, const String& id);
+
+private:
+    explicit InspectorAuditResourcesObject(Inspector::InspectorAuditAgent&);
+
+    CachedResourceClient& clientForResource(const CachedResource&);
+
+    Inspector::InspectorAuditAgent& m_auditAgent;
+
+    class InspectorAuditCachedResourceClient : public CachedResourceClient { };
+    InspectorAuditCachedResourceClient m_cachedResourceClient;
+
+    class InspectorAuditCachedFontClient : public CachedFontClient { };
+    InspectorAuditCachedFontClient m_cachedFontClient;
+
+    class InspectorAuditCachedImageClient : public CachedImageClient { };
+    InspectorAuditCachedImageClient m_cachedImageClient;
+
+    class InspectorAuditCachedRawResourceClient : public CachedRawResourceClient { };
+    InspectorAuditCachedRawResourceClient m_cachedRawResourceClient;
+
+    class InspectorAuditCachedSVGDocumentClient : public CachedSVGDocumentClient { };
+    InspectorAuditCachedSVGDocumentClient m_cachedSVGDocumentClient;
+
+    class InspectorAuditCachedStyleSheetClient : public CachedStyleSheetClient { };
+    InspectorAuditCachedStyleSheetClient m_cachedStyleSheetClient;
+
+    HashMap<String, CachedResource*> m_resources;
+};
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorAuditResourcesObjectidl"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.idl (0 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.idl                         (rev 0)
+++ trunk/Source/WebCore/inspector/InspectorAuditResourcesObject.idl    2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    ImplementationLacksVTable,
+    JSGenerateToJSObject,
+    NoInterfaceObject,
+] interface InspectorAuditResourcesObject {
+    [CallWith=Document, MayThrowException] sequence<Resource> getResources();
+    [CallWith=Document, MayThrowException] ResourceContent getResourceContent(DOMString id);
+};
+
+[
+    JSGenerateToJSObject,
+] dictionary Resource {
+    DOMString id;
+    DOMString url;
+    DOMString mimeType;
+};
+
+[
+    JSGenerateToJSObject,
+] dictionary ResourceContent {
+    DOMString data;
+    boolean base64Encoded;
+};
</ins></span></pre></div>
<a id="trunkSourceWebCoreinspectoragentsInspectorPageAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp     2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp        2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -129,6 +129,37 @@
</span><span class="cx">     return decodeBuffer(data, size, textEncodingName, result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Vector<CachedResource*> InspectorPageAgent::cachedResourcesForFrame(Frame* frame)
+{
+    Vector<CachedResource*> result;
+
+    for (auto& cachedResourceHandle : frame->document()->cachedResourceLoader().allCachedResources().values()) {
+        auto* cachedResource = cachedResourceHandle.get();
+        if (cachedResource->resourceRequest().hiddenFromInspector())
+            continue;
+
+        switch (cachedResource->type()) {
+        case CachedResource::Type::ImageResource:
+            // Skip images that were not auto loaded (images disabled in the user agent).
+#if ENABLE(SVG_FONTS)
+        case CachedResource::Type::SVGFontResource:
+#endif
+        case CachedResource::Type::FontResource:
+            // Skip fonts that were referenced in CSS but never used/downloaded.
+            if (cachedResource->stillNeedsLoad())
+                continue;
+            break;
+        default:
+            // All other CachedResource types download immediately.
+            break;
+        }
+
+        result.append(cachedResource);
+    }
+
+    return result;
+}
+
</ins><span class="cx"> void InspectorPageAgent::resourceContent(ErrorString& errorString, Frame* frame, const URL& url, String* result, bool* base64Encoded)
</span><span class="cx"> {
</span><span class="cx">     DocumentLoader* loader = assertDocumentLoader(errorString, frame);
</span><span class="lines">@@ -437,37 +468,6 @@
</span><span class="cx">     return cookies;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Vector<CachedResource*> cachedResourcesForFrame(Frame* frame)
-{
-    Vector<CachedResource*> result;
-
-    for (auto& cachedResourceHandle : frame->document()->cachedResourceLoader().allCachedResources().values()) {
-        auto* cachedResource = cachedResourceHandle.get();
-        if (cachedResource->resourceRequest().hiddenFromInspector())
-            continue;
-
-        switch (cachedResource->type()) {
-        case CachedResource::Type::ImageResource:
-            // Skip images that were not auto loaded (images disabled in the user agent).
-#if ENABLE(SVG_FONTS)
-        case CachedResource::Type::SVGFontResource:
-#endif
-        case CachedResource::Type::FontResource:
-            // Skip fonts that were referenced in CSS but never used/downloaded.
-            if (cachedResource->stillNeedsLoad())
-                continue;
-            break;
-        default:
-            // All other CachedResource types download immediately.
-            break;
-        }
-
-        result.append(cachedResource);
-    }
-
-    return result;
-}
-
</del><span class="cx"> static Vector<URL> allResourcesURLsForFrame(Frame* frame)
</span><span class="cx"> {
</span><span class="cx">     Vector<URL> result;
</span><span class="lines">@@ -474,7 +474,7 @@
</span><span class="cx"> 
</span><span class="cx">     result.append(frame->loader().documentLoader()->url());
</span><span class="cx"> 
</span><del>-    for (auto* cachedResource : cachedResourcesForFrame(frame))
</del><ins>+    for (auto* cachedResource : InspectorPageAgent::cachedResourcesForFrame(frame))
</ins><span class="cx">         result.append(cachedResource->url());
</span><span class="cx"> 
</span><span class="cx">     return result;
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectoragentsInspectorPageAgenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h       2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h  2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -76,6 +76,7 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     static bool sharedBufferContent(RefPtr<SharedBuffer>&&, const String& textEncodingName, bool withBase64Encode, String* result);
</span><ins>+    static Vector<CachedResource*> cachedResourcesForFrame(Frame*);
</ins><span class="cx">     static void resourceContent(ErrorString&, Frame*, const URL&, String* result, bool* base64Encoded);
</span><span class="cx">     static String sourceMapURLForResource(CachedResource*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectoragentspagePageAuditAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/agents/page/PageAuditAgent.cpp (242940 => 242941)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/agents/page/PageAuditAgent.cpp    2019-03-14 09:46:01 UTC (rev 242940)
+++ trunk/Source/WebCore/inspector/agents/page/PageAuditAgent.cpp       2019-03-14 10:13:57 UTC (rev 242941)
</span><span class="lines">@@ -28,8 +28,10 @@
</span><span class="cx"> 
</span><span class="cx"> #include "InspectorAuditAccessibilityObject.h"
</span><span class="cx"> #include "InspectorAuditDOMObject.h"
</span><ins>+#include "InspectorAuditResourcesObject.h"
</ins><span class="cx"> #include "JSInspectorAuditAccessibilityObject.h"
</span><span class="cx"> #include "JSInspectorAuditDOMObject.h"
</span><ins>+#include "JSInspectorAuditResourcesObject.h"
</ins><span class="cx"> #include "Page.h"
</span><span class="cx"> #include "PageConsoleClient.h"
</span><span class="cx"> #include <JavaScriptCore/CallFrame.h>
</span><span class="lines">@@ -83,11 +85,14 @@
</span><span class="cx">     if (auto* globalObject = JSC::jsCast<JSDOMGlobalObject*>(execState->lexicalGlobalObject())) {
</span><span class="cx">         JSC::JSLockHolder lock(execState);
</span><span class="cx"> 
</span><del>-        if (JSC::JSValue jsInspectorAuditAccessibilityObject = toJSNewlyCreated(execState, globalObject, InspectorAuditAccessibilityObject::create(*this))) \
</del><ins>+        if (JSC::JSValue jsInspectorAuditAccessibilityObject = toJSNewlyCreated(execState, globalObject, InspectorAuditAccessibilityObject::create(*this)))
</ins><span class="cx">             auditObject->putDirect(execState->vm(), JSC::Identifier::fromString(execState, "Accessibility"), jsInspectorAuditAccessibilityObject);
</span><span class="cx"> 
</span><del>-        if (JSC::JSValue jsInspectorAuditDOMObject = toJSNewlyCreated(execState, globalObject, InspectorAuditDOMObject::create(*this))) \
</del><ins>+        if (JSC::JSValue jsInspectorAuditDOMObject = toJSNewlyCreated(execState, globalObject, InspectorAuditDOMObject::create(*this)))
</ins><span class="cx">             auditObject->putDirect(execState->vm(), JSC::Identifier::fromString(execState, "DOM"), jsInspectorAuditDOMObject);
</span><ins>+
+        if (JSC::JSValue jsInspectorAuditResourcesObject = toJSNewlyCreated(execState, globalObject, InspectorAuditResourcesObject::create(*this)))
+            auditObject->putDirect(execState->vm(), JSC::Identifier::fromString(execState, "Resources"), jsInspectorAuditResourcesObject);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>