Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Unified Diff: third_party/WebKit/Source/core/html/HTMLScriptElement.cpp

Issue 2628733005: Experiment with hiding <script>'s 'nonce' content attribute. (Closed)
Patch Set: Ugh. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLScriptElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLScriptElement.cpp b/third_party/WebKit/Source/core/html/HTMLScriptElement.cpp
index 4bbe28de2e88c8453172bee74824b95aabb3af93..dcfb945fcb078e3133b0a0037c4bc6ddf29302c2 100644
--- a/third_party/WebKit/Source/core/html/HTMLScriptElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLScriptElement.cpp
@@ -33,6 +33,7 @@
#include "core/dom/Text.h"
#include "core/events/Event.h"
#include "core/frame/UseCounter.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
namespace blink {
@@ -86,6 +87,14 @@ void HTMLScriptElement::parseAttribute(
logUpdateAttributeIfIsolatedWorldAndInDocument("script", params);
} else if (params.name == asyncAttr) {
m_loader->handleAsyncAttribute();
+ } else if (params.name == nonceAttr) {
+ if (params.newValue == ContentSecurityPolicy::getNonceReplacementString())
+ return;
+ m_nonce = params.newValue;
+ if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled()) {
+ setAttribute(nonceAttr,
+ ContentSecurityPolicy::getNonceReplacementString());
+ }
} else {
HTMLElement::parseAttribute(params);
}

Powered by Google App Engine
This is Rietveld 408576698