Skip to content

Commit

Permalink
Expand X-Frame-Options tests
Browse files Browse the repository at this point in the history
Follows whatwg/html#5737. Closes #21730 by incorporating all of those tests.
  • Loading branch information
domenic authored Aug 18, 2020
1 parent 4dacb6e commit 29c58c0
Show file tree
Hide file tree
Showing 15 changed files with 423 additions and 347 deletions.
1 change: 1 addition & 0 deletions html/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ For historical reasons, parts of HTML have their own directories:
* [/websockets](/websockets)
* [/webstorage](/webstorage)
* [/workers](/workers)
* [/x-frame-options](/x-frame-options)
3 changes: 2 additions & 1 deletion x-frame-options/META.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
spec: https://tools.ietf.org/html/rfc7034
spec: https://html.spec.whatwg.org/#the-x-frame-options-header
suggested_reviewers:
- annevk
- mikewest
- domenic
5 changes: 3 additions & 2 deletions x-frame-options/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
This directory contains tests for
[HTTP Header Field X-Frame-Options](https://tools.ietf.org/html/rfc7034).
This directory contains tests for [`X-Frame-Options`](https://html.spec.whatwg.org/#the-x-frame-options-header).

Currently it only tests `<iframe>`. It would be nice to test `<embed>` and `<object>` as well.
43 changes: 43 additions & 0 deletions x-frame-options/deny.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>X-Frame-Options variations of DENY</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./support/helper.sub.js"></script>

<body>
<script>
"use strict";

xfo_simple_tests({
headerValue: `DENY`,
sameOriginAllowed: false,
crossOriginAllowed: false
});

xfo_simple_tests({
headerValue: `denY`,
sameOriginAllowed: false,
crossOriginAllowed: false
});

xfo_simple_tests({
headerValue: ` DENY `,
sameOriginAllowed: false,
crossOriginAllowed: false
});

xfo_simple_tests({
headerValue: `DENY`,
cspValue: `default-src 'self'`,
sameOriginAllowed: false,
crossOriginAllowed: false
});

xfo_simple_tests({
headerValue: `DENY`,
cspValue: `frame-ancestors 'self'`,
sameOriginAllowed: true,
crossOriginAllowed: false
});
</script>
61 changes: 0 additions & 61 deletions x-frame-options/deny.sub.html

This file was deleted.

23 changes: 23 additions & 0 deletions x-frame-options/get-decode-split.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>X-Frame-Options headers use the get, decode, and split algorithm</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>

<body>
<script>
"use strict";

xfo_simple_tests({
headerValue: `,SAMEORIGIN,,DENY,`,
sameOriginAllowed: false,
crossOriginAllowed: false
});

xfo_simple_tests({
headerValue: ` SAMEORIGIN, DENY`,
sameOriginAllowed: false,
crossOriginAllowed: false
});
</script>
59 changes: 59 additions & 0 deletions x-frame-options/invalid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>X-Frame-Options invalid values</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./support/helper.sub.js"></script>

<body>
<script>
"use strict";

xfo_simple_tests({
headerValue: `INVALID`,
sameOriginAllowed: true,
crossOriginAllowed: true
});

xfo_simple_tests({
headerValue: `ALLOW-FROM https://example.com/`,
sameOriginAllowed: true,
crossOriginAllowed: true
});

xfo_simple_tests({
headerValue: `ALLOW-FROM=https://example.com/`,
sameOriginAllowed: true,
crossOriginAllowed: true
});

xfo_simple_tests({
headerValue: `ALLOWALL`,
sameOriginAllowed: true,
crossOriginAllowed: true
});

xfo_simple_tests({
headerValue: `"DENY"`,
sameOriginAllowed: true,
crossOriginAllowed: true
});

xfo_simple_tests({
headerValue: `"SAMEORIGIN"`,
sameOriginAllowed: true,
crossOriginAllowed: true
});

xfo_simple_tests({
headerValue: `"SAMEORIGIN,DENY"`,
sameOriginAllowed: true,
crossOriginAllowed: true
});

xfo_simple_tests({
headerValue: ``,
sameOriginAllowed: true,
crossOriginAllowed: true
});
</script>
84 changes: 0 additions & 84 deletions x-frame-options/invalid.sub.html

This file was deleted.

Loading

0 comments on commit 29c58c0

Please sign in to comment.