<!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>[198178] 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/198178">198178</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2016-03-14 17:39:59 -0700 (Mon, 14 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: Display Content Security Policy hash in details sidebar for script and style elements
https://bugs.webkit.org/show_bug.cgi?id=155466
<rdar://problem/25152480>
Reviewed by Joseph Pecoraro and Timothy Hatcher.
Source/JavaScriptCore:
Add property contentSecurityPolicyHash to store the CSP hash for an HTML style element or an
applicable HTML script element.
* inspector/protocol/DOM.json:
Source/WebCore:
For convenience, display the SHA-256 Content Security Policy (CSP) hash in the node details
sidebar for the selected HTML script element or HTML style element. A CSP script hash is
only applicable to inline JavaScript scripts. Therefore, we will display a hash for HTML
script elements only if they do not have a src attribute.
Tests: inspector/dom/csp-big5-hash.html
inspector/dom/csp-hash.html
* inspector/InspectorDOMAgent.cpp:
(WebCore::computeContentSecurityPolicySHA256Hash): Added.
(WebCore::InspectorDOMAgent::buildObjectForNode): For an applicable HTML script- or style-
element, pass the computed SHA-256 CSP hash to the Inspector front end.
Source/WebInspectorUI:
* Localizations/en.lproj/localizedStrings.js: Add English localized string for the CSP hash UI label.
* UserInterface/Models/DOMNode.js:
(WebInspector.DOMNode): Initialize the instance variable this._contentSecurityPolicyHash
with the value passed from the Inspector back end.
(WebInspector.DOMNode.prototype.contentSecurityPolicyHash): Returns the CSP hash for this node.
* UserInterface/Views/DOMNodeDetailsSidebarPanel.js:
(WebInspector.DOMNodeDetailsSidebarPanel): Append a row to the end of section Identity to display
the CSP hash (if applicable).
(WebInspector.DOMNodeDetailsSidebarPanel.prototype.refresh): Query the underlying WebInspector.DOMNode
for the CSP hash of the selected node.
LayoutTests:
Add tests to ensure that the WebInspector.DOMNode object associated with an HTML style element
or applicable HTML script element has a valid CSP hash.
* inspector/dom/csp-big5-hash-expected.txt: Added.
* inspector/dom/csp-big5-hash.html: Added.
* inspector/dom/csp-hash-expected.txt: Added.
* inspector/dom/csp-hash.html: 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="#trunkSourceJavaScriptCoreinspectorprotocolDOMjson">trunk/Source/JavaScriptCore/inspector/protocol/DOM.json</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorDOMAgentcpp">trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs">trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsDOMNodejs">trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsDOMNodeDetailsSidebarPaneljs">trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectordomcspbig5hashexpectedtxt">trunk/LayoutTests/inspector/dom/csp-big5-hash-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectordomcspbig5hashhtml">trunk/LayoutTests/inspector/dom/csp-big5-hash.html</a></li>
<li><a href="#trunkLayoutTestsinspectordomcsphashexpectedtxt">trunk/LayoutTests/inspector/dom/csp-hash-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectordomcsphashhtml">trunk/LayoutTests/inspector/dom/csp-hash.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198177 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-15 00:22:45 UTC (rev 198177)
+++ trunk/LayoutTests/ChangeLog        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-03-14 Daniel Bates <dabates@apple.com>
+
+ Web Inspector: Display Content Security Policy hash in details sidebar for script and style elements
+ https://bugs.webkit.org/show_bug.cgi?id=155466
+ <rdar://problem/25152480>
+
+ Reviewed by Joseph Pecoraro and Timothy Hatcher.
+
+ Add tests to ensure that the WebInspector.DOMNode object associated with an HTML style element
+ or applicable HTML script element has a valid CSP hash.
+
+ * inspector/dom/csp-big5-hash-expected.txt: Added.
+ * inspector/dom/csp-big5-hash.html: Added.
+ * inspector/dom/csp-hash-expected.txt: Added.
+ * inspector/dom/csp-hash.html: Added.
+
</ins><span class="cx"> 2016-03-14 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> REGRESSION(r194394): >2x slow-down on CDjs
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordomcspbig5hashexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/dom/csp-big5-hash-expected.txt (0 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/csp-big5-hash-expected.txt         (rev 0)
+++ trunk/LayoutTests/inspector/dom/csp-big5-hash-expected.txt        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+Test for Content Security Policy hash support on DOM.DOMNode in a document with character set Big5.
+
+
+PASS: Got DOMNode for #stylesheet-1
+PASS: DOMNode has hash sha256-duNBvCmzrFc3RVVqS8ufweBf2QOq1THuEh3UZWP7ZpU=
+
+PASS: Got DOMNode for #script-1
+PASS: DOMNode has hash sha256-0eDk4my9q3qcCQTZ02clVW0RxDNPW9n9lXTCdyGY4Js=
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectordomcspbig5hashhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/dom/csp-big5-hash.html (0 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/csp-big5-hash.html         (rev 0)
+++ trunk/LayoutTests/inspector/dom/csp-big5-hash.html        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="Big5">
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test() {
+ let testCases = [
+ {selector: "#stylesheet-1", hash: "sha256-duNBvCmzrFc3RVVqS8ufweBf2QOq1THuEh3UZWP7ZpU="},
+ {selector: "#script-1", hash: "sha256-0eDk4my9q3qcCQTZ02clVW0RxDNPW9n9lXTCdyGY4Js="},
+ ];
+ WebInspector.domTreeManager.requestDocument(function(documentNode) {
+ for (let {selector, hash} of testCases) {
+ WebInspector.domTreeManager.querySelector(documentNode.id, selector, function(nodeId) {
+ let domNode = WebInspector.domTreeManager.nodeForId(nodeId);
+ InspectorTest.log("");
+ InspectorTest.expectThat(domNode, `Got DOMNode for ${selector}`);
+ InspectorTest.expectThat(domNode.contentSecurityPolicyHash() === hash, `DOMNode has hash ${hash}`);
+ });
+ }
+ InspectorTest.completeTest();
+ });
+}
+</script>
+</head>
+<body onload="runTest()">
+ <p>Test for Content Security Policy hash support on DOM.DOMNode in a document with character set Big5.</p>
+ <style id="stylesheet-1">#test1 { background-color: blue; } /* \xA4\xF4 */</style>
+ <script id="script-1">var thisIsAnInlineScript = true; // \xA4\xF4</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectordomcsphashexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/dom/csp-hash-expected.txt (0 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/csp-hash-expected.txt         (rev 0)
+++ trunk/LayoutTests/inspector/dom/csp-hash-expected.txt        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+Test for Content Security Policy hash support on DOM.DOMNode.
+
+
+PASS: Got DOMNode for #stylesheet-without-whitespace
+PASS: DOMNode has hash sha256-NW7+Fm6YV404pkklaopT0jgCBCmfOAn0K+NtIfyPN4A=
+
+PASS: Got DOMNode for #stylesheet-with-whitespace
+PASS: DOMNode has hash sha256-b5lOENncCyOGrTlLzIlify6a9ddSaiGTBFF/jcYcj0k=
+
+PASS: Got DOMNode for #stylesheet-with-ignored-charset
+PASS: DOMNode has hash sha256-Nyij5I3ne5qy0HQHZD8sKjbedAqMQDJ2riYqGniSYTc=
+
+PASS: Got DOMNode for #script-without-whitespace
+PASS: DOMNode has hash sha256-tVRjKJA9OYKEzYP5h7H2XbuSVgOjLD74/zqHyl+/xOM=
+
+PASS: Got DOMNode for #script-with-whitespace
+PASS: DOMNode has hash sha256-hSQRzSxNGYtVe272nNs1poXibikReR/Y+NfX6TsCqzo=
+
+PASS: Got DOMNode for #script-with-unicode-code-point-00C5
+PASS: DOMNode has hash sha256-YcKgriaBGkU6FsWZXgDLv4Wo5UZ5Qe5hNp6Psb3RJOE=
+
+PASS: Got DOMNode for #script-with-unicode-code-point-212B
+PASS: DOMNode has hash sha256-YcKgriaBGkU6FsWZXgDLv4Wo5UZ5Qe5hNp6Psb3RJOE=
+
+PASS: Got DOMNode for #external-stylesheet
+PASS: DOMNode has hash undefined
+
+PASS: Got DOMNode for #external-script
+PASS: DOMNode has hash undefined
+
+PASS: Got DOMNode for #external-stylesheet
+PASS: DOMNode has hash undefined
+
+PASS: Got DOMNode for #paragraph
+PASS: DOMNode has hash undefined
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectordomcsphashhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/dom/csp-hash.html (0 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/dom/csp-hash.html         (rev 0)
+++ trunk/LayoutTests/inspector/dom/csp-hash.html        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF8">
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test() {
+ let testCases = [
+ {selector: "#stylesheet-without-whitespace", hash: "sha256-NW7+Fm6YV404pkklaopT0jgCBCmfOAn0K+NtIfyPN4A="},
+ {selector: "#stylesheet-with-whitespace", hash: "sha256-b5lOENncCyOGrTlLzIlify6a9ddSaiGTBFF/jcYcj0k="},
+ {selector: "#stylesheet-with-ignored-charset", hash: "sha256-Nyij5I3ne5qy0HQHZD8sKjbedAqMQDJ2riYqGniSYTc="},
+ {selector: "#script-without-whitespace", hash: "sha256-tVRjKJA9OYKEzYP5h7H2XbuSVgOjLD74/zqHyl+/xOM="},
+ {selector: "#script-with-whitespace", hash: "sha256-hSQRzSxNGYtVe272nNs1poXibikReR/Y+NfX6TsCqzo="},
+ {selector: "#script-with-unicode-code-point-00C5", hash: "sha256-YcKgriaBGkU6FsWZXgDLv4Wo5UZ5Qe5hNp6Psb3RJOE="},
+ {selector: "#script-with-unicode-code-point-212B", hash: "sha256-YcKgriaBGkU6FsWZXgDLv4Wo5UZ5Qe5hNp6Psb3RJOE="}, // Same hash as for script #script-with-unicode-code-point-00C5.
+ {selector: "#external-stylesheet", hash: undefined},
+ {selector: "#external-script", hash: undefined},
+ {selector: "#external-stylesheet", hash: undefined},
+ {selector: "#paragraph", hash: undefined},
+ ];
+
+ WebInspector.domTreeManager.requestDocument(function(documentNode) {
+ for (let {selector, hash} of testCases) {
+ WebInspector.domTreeManager.querySelector(documentNode.id, selector, function(nodeId) {
+ let domNode = WebInspector.domTreeManager.nodeForId(nodeId);
+ InspectorTest.log("");
+ InspectorTest.expectThat(domNode, `Got DOMNode for ${selector}`);
+ InspectorTest.expectThat(domNode.contentSecurityPolicyHash() === hash, `DOMNode has hash ${hash}`);
+ });
+ }
+ InspectorTest.completeTest();
+ });
+}
+</script>
+</head>
+<body onload="runTest()">
+ <p>Test for Content Security Policy hash support on DOM.DOMNode.</p>
+
+ <!-- Elements that can have a Content Security Policy hash -->
+ <style id="stylesheet-without-whitespace">#test1 { background-color: blue; }</style>
+ <style id="stylesheet-with-whitespace">
+ #test2 {
+ background-color: yellow;
+ }
+ </style>
+ <style id="stylesheet-with-ignored-charset">
+ @charset "Big5"; /* This should be ignored. */
+ #test3 {
+ background-color: magenta;
+ }
+ </style>
+
+ <script id="script-without-whitespace">var thisIsAnInlineScript = true;</script>
+ <script id="script-with-whitespace">
+ var thisIsAnotherInlineScript = true;
+ </script>
+ <script id="script-with-unicode-code-point-00C5">
+ // Å
+ </script>
+ <!-- Hash of this script should be equivalent to hash of script script-with-unicode-code-point-00C5. -->
+ <script id="script-with-unicode-code-point-212B">
+ // Å
+ </script>
+
+ <!-- Elements that cannot have a Content Security Policy hash -->
+ <!-- FIXME: We should make this more comprehensive. -->
+ <link id="external-stylesheet" rel="stylesheet" href="">
+ <script id="external-script" src=""></script>
+ <p id="paragraph"></p>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (198177 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-03-15 00:22:45 UTC (rev 198177)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-03-14 Daniel Bates <dabates@apple.com>
+
+ Web Inspector: Display Content Security Policy hash in details sidebar for script and style elements
+ https://bugs.webkit.org/show_bug.cgi?id=155466
+ <rdar://problem/25152480>
+
+ Reviewed by Joseph Pecoraro and Timothy Hatcher.
+
+ Add property contentSecurityPolicyHash to store the CSP hash for an HTML style element or an
+ applicable HTML script element.
+
+ * inspector/protocol/DOM.json:
+
</ins><span class="cx"> 2016-03-14 Joonghun Park <jh718.park@samsung.com>
</span><span class="cx">
</span><span class="cx"> Purge PassRefPtr from ArrayBuffer, ArchiveResource, Pasteboard, LegacyWebArchive and DataObjectGtk
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolDOMjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/DOM.json (198177 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/DOM.json        2016-03-15 00:22:45 UTC (rev 198177)
+++ trunk/Source/JavaScriptCore/inspector/protocol/DOM.json        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -51,7 +51,8 @@
</span><span class="cx"> { "name": "shadowRoots", "type": "array", "optional": true, "items": { "$ref": "Node" }, "description": "Shadow root list for given element host." },
</span><span class="cx"> { "name": "templateContent", "$ref": "Node", "optional": true, "description": "Content document fragment for template elements" },
</span><span class="cx"> { "name": "pseudoElements", "type": "array", "items": { "$ref": "Node" }, "optional": true, "description": "Pseudo elements associated with this node." },
</span><del>- { "name": "role", "type": "string", "optional": true, "description": "Computed value for first recognized role token, default role per element, or overridden role." }
</del><ins>+ { "name": "role", "type": "string", "optional": true, "description": "Computed value for first recognized role token, default role per element, or overridden role." },
+ { "name": "contentSecurityPolicyHash", "type": "string", "optional": true, "description": "Computed SHA-256 Content Security Policy hash source for given element." }
</ins><span class="cx"> ],
</span><span class="cx"> "description": "DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type."
</span><span class="cx"> },
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198177 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-15 00:22:45 UTC (rev 198177)
+++ trunk/Source/WebCore/ChangeLog        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2016-03-14 Daniel Bates <dabates@apple.com>
+
+ Web Inspector: Display Content Security Policy hash in details sidebar for script and style elements
+ https://bugs.webkit.org/show_bug.cgi?id=155466
+ <rdar://problem/25152480>
+
+ Reviewed by Joseph Pecoraro and Timothy Hatcher.
+
+ For convenience, display the SHA-256 Content Security Policy (CSP) hash in the node details
+ sidebar for the selected HTML script element or HTML style element. A CSP script hash is
+ only applicable to inline JavaScript scripts. Therefore, we will display a hash for HTML
+ script elements only if they do not have a src attribute.
+
+ Tests: inspector/dom/csp-big5-hash.html
+ inspector/dom/csp-hash.html
+
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::computeContentSecurityPolicySHA256Hash): Added.
+ (WebCore::InspectorDOMAgent::buildObjectForNode): For an applicable HTML script- or style-
+ element, pass the computed SHA-256 CSP hash to the Inspector front end.
+
</ins><span class="cx"> 2016-03-14 Joonghun Park <jh718.park@samsung.com>
</span><span class="cx">
</span><span class="cx"> Purge PassRefPtr from ArrayBuffer, ArchiveResource, Pasteboard, LegacyWebArchive and DataObjectGtk
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorDOMAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (198177 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp        2016-03-15 00:22:45 UTC (rev 198177)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2009, 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2009, 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2011 Google Inc. All rights reserved.
</span><span class="cx"> * Copyright (C) 2009 Joseph Pecoraro
</span><span class="cx"> *
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> #include "ContainerNode.h"
</span><span class="cx"> #include "Cookie.h"
</span><span class="cx"> #include "CookieJar.h"
</span><ins>+#include "CryptoDigest.h"
</ins><span class="cx"> #include "DOMEditor.h"
</span><span class="cx"> #include "DOMPatchSupport.h"
</span><span class="cx"> #include "DOMWindow.h"
</span><span class="lines">@@ -86,6 +87,7 @@
</span><span class="cx"> #include "StyleResolver.h"
</span><span class="cx"> #include "StyleSheetList.h"
</span><span class="cx"> #include "Text.h"
</span><ins>+#include "TextNodeTraversal.h"
</ins><span class="cx"> #include "XPathResult.h"
</span><span class="cx"> #include "htmlediting.h"
</span><span class="cx"> #include "markup.h"
</span><span class="lines">@@ -93,6 +95,7 @@
</span><span class="cx"> #include <inspector/InjectedScript.h>
</span><span class="cx"> #include <inspector/InjectedScriptManager.h>
</span><span class="cx"> #include <runtime/JSCInlines.h>
</span><ins>+#include <wtf/text/Base64.h>
</ins><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span><span class="lines">@@ -1268,6 +1271,19 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static String computeContentSecurityPolicySHA256Hash(const Element& element)
+{
+ // FIXME: Compute the digest with respect to the raw bytes received from the page.
+ // See <https://bugs.webkit.org/show_bug.cgi?id=155184>.
+ TextEncoding documentEncoding = element.document().textEncoding();
+ const TextEncoding& encodingToUse = documentEncoding.isValid() ? documentEncoding : UTF8Encoding();
+ CString content = encodingToUse.encode(TextNodeTraversal::contentsAsString(element), EntitiesForUnencodables);
+ auto cryptoDigest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_256);
+ cryptoDigest->addBytes(content.data(), content.length());
+ Vector<uint8_t> digest = cryptoDigest->computeHash();
+ return makeString("sha256-", base64Encode(digest.data(), digest.size()));
+}
+
</ins><span class="cx"> Ref<Inspector::Protocol::DOM::Node> InspectorDOMAgent::buildObjectForNode(Node* node, int depth, NodeToIdMap* nodesMap)
</span><span class="cx"> {
</span><span class="cx"> int id = bind(node, nodesMap);
</span><span class="lines">@@ -1341,6 +1357,9 @@
</span><span class="cx"> value->setTemplateContent(buildObjectForNode(downcast<HTMLTemplateElement>(element).content(), 0, nodesMap));
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+ if (is<HTMLStyleElement>(element) || (is<HTMLScriptElement>(element) && !element.fastHasAttribute(HTMLNames::srcAttr)))
+ value->setContentSecurityPolicyHash(computeContentSecurityPolicySHA256Hash(element));
+
</ins><span class="cx"> if (element.pseudoId()) {
</span><span class="cx"> Inspector::Protocol::DOM::PseudoType pseudoType;
</span><span class="cx"> if (pseudoElementType(element.pseudoId(), &pseudoType))
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (198177 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-03-15 00:22:45 UTC (rev 198177)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-03-14 Daniel Bates <dabates@apple.com>
+
+ Web Inspector: Display Content Security Policy hash in details sidebar for script and style elements
+ https://bugs.webkit.org/show_bug.cgi?id=155466
+ <rdar://problem/25152480>
+
+ Reviewed by Joseph Pecoraro and Timothy Hatcher.
+
+ * Localizations/en.lproj/localizedStrings.js: Add English localized string for the CSP hash UI label.
+ * UserInterface/Models/DOMNode.js:
+ (WebInspector.DOMNode): Initialize the instance variable this._contentSecurityPolicyHash
+ with the value passed from the Inspector back end.
+ (WebInspector.DOMNode.prototype.contentSecurityPolicyHash): Returns the CSP hash for this node.
+ * UserInterface/Views/DOMNodeDetailsSidebarPanel.js:
+ (WebInspector.DOMNodeDetailsSidebarPanel): Append a row to the end of section Identity to display
+ the CSP hash (if applicable).
+ (WebInspector.DOMNodeDetailsSidebarPanel.prototype.refresh): Query the underlying WebInspector.DOMNode
+ for the CSP hash of the selected node.
+
</ins><span class="cx"> 2016-03-14 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: REGRESSION(r197974): HeapAllocationsTimelineView broken, doesn't handle Timeline Sidebar Navigation removal
</span></span></pre></div>
<a id="trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (198177 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2016-03-15 00:22:45 UTC (rev 198177)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -188,6 +188,7 @@
</span><span class="cx"> localizedStrings["Container Regions"] = "Container Regions";
</span><span class="cx"> localizedStrings["Content"] = "Content";
</span><span class="cx"> localizedStrings["Content Flow"] = "Content Flow";
</span><ins>+localizedStrings["CSP Hash"] = "CSP Hash";
</ins><span class="cx"> localizedStrings["Content Security Policy violation of directive: %s"] = "Content Security Policy violation of directive: %s";
</span><span class="cx"> localizedStrings["Continue script execution (%s or %s)"] = "Continue script execution (%s or %s)";
</span><span class="cx"> localizedStrings["Continue to Here"] = "Continue to Here";
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsDOMNodejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js (198177 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js        2016-03-15 00:22:45 UTC (rev 198177)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /*
</span><span class="cx"> * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
</span><span class="cx"> * Copyright (C) 2009 Joseph Pecoraro
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> this._nodeValue = payload.nodeValue;
</span><span class="cx"> this._pseudoType = payload.pseudoType;
</span><span class="cx"> this._computedRole = payload.role;
</span><ins>+ this._contentSecurityPolicyHash = payload.contentSecurityPolicyHash;
</ins><span class="cx">
</span><span class="cx"> if (this._nodeType === Node.DOCUMENT_NODE)
</span><span class="cx"> this.ownerDocument = this;
</span><span class="lines">@@ -228,6 +229,11 @@
</span><span class="cx"> return this._computedRole;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ contentSecurityPolicyHash()
+ {
+ return this._contentSecurityPolicyHash;
+ }
+
</ins><span class="cx"> hasAttributes()
</span><span class="cx"> {
</span><span class="cx"> return this._attributes.length > 0;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsDOMNodeDetailsSidebarPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js (198177 => 198178)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js        2016-03-15 00:22:45 UTC (rev 198177)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js        2016-03-15 00:39:59 UTC (rev 198178)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -38,8 +38,9 @@
</span><span class="cx"> this._identityNodeTypeRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Type"));
</span><span class="cx"> this._identityNodeNameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name"));
</span><span class="cx"> this._identityNodeValueRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Value"));
</span><ins>+ this._identityNodeContentSecurityPolicyHashRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("CSP Hash"));
</ins><span class="cx">
</span><del>- var identityGroup = new WebInspector.DetailsSectionGroup([this._identityNodeTypeRow, this._identityNodeNameRow, this._identityNodeValueRow]);
</del><ins>+ var identityGroup = new WebInspector.DetailsSectionGroup([this._identityNodeTypeRow, this._identityNodeNameRow, this._identityNodeValueRow, this._identityNodeContentSecurityPolicyHashRow]);
</ins><span class="cx"> var identitySection = new WebInspector.DetailsSection("dom-node-identity", WebInspector.UIString("Identity"), [identityGroup]);
</span><span class="cx">
</span><span class="cx"> this._attributesDataGridRow = new WebInspector.DetailsSectionDataGridRow(null, WebInspector.UIString("No Attributes"));
</span><span class="lines">@@ -104,6 +105,7 @@
</span><span class="cx"> this._identityNodeTypeRow.value = this._nodeTypeDisplayName();
</span><span class="cx"> this._identityNodeNameRow.value = domNode.nodeNameInCorrectCase();
</span><span class="cx"> this._identityNodeValueRow.value = domNode.nodeValue();
</span><ins>+ this._identityNodeContentSecurityPolicyHashRow.value = domNode.contentSecurityPolicyHash();
</ins><span class="cx">
</span><span class="cx"> this._refreshAttributes();
</span><span class="cx"> this._refreshProperties();
</span></span></pre>
</div>
</div>
</body>
</html>