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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/require-sri-for/require-sri-for-style-reportonly-allowed.php

Issue 2056183002: Implement the `require-sri-for` CSP directive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated tests Created 4 years, 5 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/require-sri-for/require-sri-for-style-reportonly-allowed.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/require-sri-for/require-sri-for-style-reportonly-allowed.php b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/require-sri-for/require-sri-for-style-reportonly-allowed.php
new file mode 100644
index 0000000000000000000000000000000000000000..d4631d9af7e68f54d85fd301c4ccafc40484a907
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/require-sri-for/require-sri-for-style-reportonly-allowed.php
@@ -0,0 +1,28 @@
+<?php
+ header("Content-Security-Policy-Report-Only: require-sri-for style; script-src 'self' 'unsafe-inline'");
+?>
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<link rel="stylesheet" crossorigin integrity="sha256-48sSy1L+0pGBMr3XQog56zBcXid1hhmpAwenUuKoe5w=" href="/security/contentSecurityPolicy/resources/style-set-red.css">
+<script>
+ async_test(t => {
+ var watcher = new EventWatcher(t, document, ['securitypolicyviolation']);
+ watcher
+ .wait_for('securitypolicyviolation')
+ .then(t.step_func_done(e => {
+ assert_equals(e.blockedURI, "http://127.0.0.1:8000/security/contentSecurityPolicy/blue.css");
+ assert_equals(e.lineNumber, 16);
+ }));
+ }, "Stylesheets without integrity generate reports.");
+</script>
+<link rel="stylesheet" href="/security/contentSecurityPolicy/blue.css">
+<script>
+ async_test(t => {
+ window.onload = t.step_func_done(_ => {
+ assert_equals(document.styleSheets.length, 2);
+ assert_equals(document.styleSheets[0].href, "http://127.0.0.1:8000/security/contentSecurityPolicy/resources/style-set-red.css");
+ assert_equals(document.styleSheets[1].href, "http://127.0.0.1:8000/security/contentSecurityPolicy/blue.css");
+ });
+ }, "Stylesheet with integrity loads, and does not trigger reports.");
+</script>

Powered by Google App Engine
This is Rietveld 408576698