Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions content-security-policy/blob/frame-src-blob-matches-blob.sub.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'; frame-src blob:;">
<title>frame-src-blob-matches-blob</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src='../support/logTest.sub.js?logs=["PASS (1/1)"]'></script>
<script src='../support/alertAssert.sub.js?alerts=[]'></script>
</head>

<body>
<p>
blob: URLs should match if the blob: scheme is explicitly specified in the frame-src directive.
</p>
<script>
window.addEventListener('securitypolicyviolation', function(e) {
log("FAIL");
});

var b = new Blob(['<html><body></body></html>'], {
type: 'text/html'
});
var iframe = document.createElement('iframe');
iframe.src = URL.createObjectURL(b);
iframe.onload = function() {
log("PASS (1/1)");
};
document.body.appendChild(iframe);

</script>
<div id="log"></div>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'; frame-src 'self';">
<title>frame-src-self-does-not-match-blob</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src='../support/logTest.sub.js?logs=["violated-directive=frame-src"]'></script>
<script src='../support/alertAssert.sub.js?alerts=[]'></script>
</head>

<body>
<p>
blob: URLs should not match the &apos;self&apos; source in a frame-src directive because blob: is a non-HTTP(S) scheme that must be explicitly listed.
</p>
<script>
window.addEventListener('securitypolicyviolation', function(e) {
log("violated-directive=" + e.violatedDirective);
});

var b = new Blob(['<html><body>FAIL</body></html>'], {
type: 'text/html'
});
var iframe = document.createElement('iframe');
iframe.src = URL.createObjectURL(b);
document.body.appendChild(iframe);

</script>
<div id="log"></div>
</body>

</html>
Loading