Skip to content

Commit c78ac0e

Browse files
committed
Add spec for Content-Security-Policy: frame-src
1 parent a72ce63 commit c78ac0e

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

middleware/policy.es

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ const
33
// `default-src 'self' https://${domain};`
44
= [`'none'`]
55

6+
, frames
7+
// `frame-src 'self' https://${domain};`
8+
= [`'none'`]
9+
610
, styles
711
// `style-src 'self' 'unsafe-inline' https://cdn.example.com
812
= [`'none'`]
913

1014
, policies = [
1115
, `default-src ${ defaults.join ` ` };`
16+
, `frame-src ${ frames.join ` ` };`
1217
, `style-src ${ styles.join ` ` };`
1318
]
1419

middleware/policy.test

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,26 @@ test ("Content-Security-Policy: default-src 'none'", async t => {
2727
})
2828

2929

30-
test ("Content-Security-Policy: frame-src 'self'")
30+
test.only ("Content-Security-Policy: frame-src 'self'", async t => {
31+
32+
const
33+
server = (new Server).serve ``
34+
, response = await fetch ('http://localhost:8181/')
35+
, policy = response.headers.get ('content-security-policy')
36+
37+
38+
t.ok ( policy.includes `frame-src 'none'` )
39+
40+
server.close ``
41+
t.end ()
42+
})
43+
44+
3145
test ("Content-Security-Policy: connect-src 'self'")
3246
test ("Content-Security-Policy: img-src 'self' https://cdn.example.com")
3347

3448

35-
test.only ("Content-Security-Policy: style-src 'none'", async t => {
49+
test ("Content-Security-Policy: style-src 'none'", async t => {
3650

3751
const
3852
server = (new Server).serve ``

0 commit comments

Comments
 (0)