<meta http-equiv="Content-Security-Policy" content="default-src 'self'" />CSPViolationReport / notebook
CSPViolationReport
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
<!-- This should generate a CSP violation -->
<script src="https://apis.google.com/js/platform.js"></script>const observer = new ReportingObserver(
(reports, observer) => {
reports.forEach((violation) => {
console.log(violation);
console.log(JSON.stringify(violation));
});
},
{
types: ["csp-violation"],
buffered: true,
},
);
observer.observe();<!-- This should generate a CSP violation -->
<script src="https://apis.google.com/js/platform.js"></script>