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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/mixedContent/strict-mode-image-reportonly.https.php

Issue 2002003002: Generate CSP violation reports for 'block-all-mixed-content' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: PHP Created 4 years, 7 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/mixedContent/strict-mode-image-reportonly.https.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/mixedContent/strict-mode-image-reportonly.https.php b/third_party/WebKit/LayoutTests/http/tests/security/mixedContent/strict-mode-image-reportonly.https.php
new file mode 100644
index 0000000000000000000000000000000000000000..fe5c2f312469b8cef613962463fc18736a39c1dd
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/mixedContent/strict-mode-image-reportonly.https.php
@@ -0,0 +1,39 @@
+<?php
+ header("Content-Security-Policy-Report-Only: block-all-mixed-content");
+?>
+<!doctype html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+ async_test(t => {
+ var i = document.createElement('img');
+ i.onerror = t.assert_unreached;
+ i.onload = t.step_func_done(_ => {
+ assert_equals(128, i.naturalWidth);
+ assert_equals(128, i.naturalHeight);
+ });
+ i.src = "http://127.0.0.1:8080/security/resources/compass.jpg?t=1";
+ }, "Mixed images are allowed in the presence of 'block-all-mixed-content' in report-only mode.");
+
+ async_test(t => {
+ var i = document.createElement('img');
+ document.addEventListener('securitypolicyviolation', t.step_func_done(e => {
+ var expectations = {
+ 'documentURI': document.location.toString(),
+ 'referrer': document.referrer,
+ 'blockedURI': 'http://127.0.0.1:8080',
+ 'violatedDirective': 'block-all-mixed-content',
+ 'effectiveDirective': 'block-all-mixed-content',
+ 'originalPolicy': 'block-all-mixed-content',
+ 'sourceFile': '',
+ 'lineNumber': 0,
+ 'columnNumber': 0,
+ 'statusCode': 0
+ };
+ for (key in expectations)
+ assert_equals(expectations[key], e[key], key);
+ }));
+ i.src = "http://127.0.0.1:8080/security/resources/compass.jpg?t=2";
+ }, "Mixed images generate CSP violation reports in the presence of 'block-all-mixed-content'.");
+</script>

Powered by Google App Engine
This is Rietveld 408576698