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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-allowed.php

Issue 2020223002: Refactor nonce support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@inline
Patch Set: Rebase. Created 4 years, 6 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/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-allowed.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-allowed.php b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-allowed.php
new file mode 100644
index 0000000000000000000000000000000000000000..5be8f11239a976fecf5edb2e01ad06a3b262d380
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-allowed.php
@@ -0,0 +1,49 @@
+<?php
+ header("Content-Security-Policy: script-src 'unsafe-inline' 'self'");
+ header("Content-Security-Policy-Report-Only: script-src 'self' 'nonce-abc'");
+?>
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script nonce="abc">
+ async_test(t => {
+ var watcher = new EventWatcher(t, document, ['securitypolicyviolation','securitypolicyviolation']);
+ watcher
+ .wait_for('securitypolicyviolation')
+ .then(t.step_func(e => {
+ assert_equals(e.blockedURI, "inline");
+ assert_equals(e.lineNumber, 29);
+ return watcher.wait_for('securitypolicyviolation');
+ }))
+ .then(t.step_func_done(e => {
+ assert_equals(e.blockedURI, "inline");
+ assert_equals(e.lineNumber, 32);
+ }));
+ }, "Unnonced script blocks generate reports.");
+
+ var testList = [
+ async_test("Script without nonce executes"),
+ async_test("Script with incorrect nonce executes")
+ ];
+ var executed = [
+ false,
+ false
+ ];
+</script>
+<script>
+ executed[0] = true;
+</script>
+<script nonce="xyz">
+ executed[1] = true;
+</script>
+<script nonce="abc">
+ testList[0].step(_ => {
+ assert_true(executed[0]);
+ testList[0].done();
+ });
+
+ testList[1].step(_ => {
+ assert_true(executed[1]);
+ testList[1].done();
+ });
+</script>

Powered by Google App Engine
This is Rietveld 408576698