-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[html] Add tests for parsing COOP values #20873
Merged
zcorpan
merged 9 commits into
web-platform-tests:master
from
bocoup:html-coop-parsing-2
Aug 25, 2020
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1de7e8d
[html] Add tests for parsing COOP values
jugglinmike 2843a50
Update tests to draft-ietf-httpbis-header-structure-19 and current HT…
zcorpan 05c9fe2
Fix tests - leading and trailing OWS are removed by HTTP
zcorpan 44ce78b
Fix typo
zcorpan 9839b15
fixup! [html] Add tests for parsing COOP values
jugglinmike 31c5e51
Test bytes by using URL percent encoding
zcorpan a7de38c
Revert "Test bytes by using URL percent encoding"
zcorpan 84cfdf8
Use an object to represent the 0xFF byte test
zcorpan 76c0730
escaped -> encoded
zcorpan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="resources/common.js"></script> | ||
|
||
<div id=log></div> | ||
<script> | ||
|
||
let tests = [ | ||
// popup Origin, popup COOP, expect opener | ||
|
||
// None of the following should be recognized as "same-origin" (hence the | ||
// "expected opener" value of `true`). | ||
[SAME_ORIGIN, "same\u2014origin", true], // non-ASCII character (em dash) | ||
[SAME_ORIGIN, "same-origin;", true], | ||
[SAME_ORIGIN, "\u000bsame-origin\u000b", true], // vertical tab | ||
[SAME_ORIGIN, "\u000csame-origin\u000c", true], // form feed | ||
[SAME_ORIGIN, "\u000dsame-origin\u000d", true], // carriage return | ||
[SAME_ORIGIN, "Same-origin", true], | ||
[SAME_ORIGIN, "same-origin;\tfoo=bar", true], | ||
[SAME_ORIGIN, "same-origin ;foo=bar", true], | ||
[SAME_ORIGIN, "same-origin; foo=bar;", true], | ||
[SAME_ORIGIN, "\"same-origin\"", true], // HTTP structured fields "string" item | ||
[SAME_ORIGIN, ":c2FtZS1vcmlnaW4=:", true], // HTTP structured fields "byte sequence" item | ||
[SAME_ORIGIN, "?1", true], // HTTP structured fields "boolean" item | ||
[SAME_ORIGIN, "1", true], // HTTP structured fields "integer or decimal" item | ||
[SAME_ORIGIN, "$same-origin", true], // the item type is unrecognized | ||
[SAME_ORIGIN, "same-origin same-origin", true], | ||
[SAME_ORIGIN, "same-origin,same-origin", true], | ||
[SAME_ORIGIN, "*same-origin ", true], | ||
|
||
// All of the following should be recognized as "same-origin" (hence the | ||
// "expected opener" value of `false`). | ||
[SAME_ORIGIN, " same-origin", false], | ||
[SAME_ORIGIN, "same-origin ", false], | ||
[SAME_ORIGIN, "\tsame-origin", true], | ||
[SAME_ORIGIN, "same-origin\t", true], | ||
[SAME_ORIGIN, "same-origin;same-origin", false], | ||
[SAME_ORIGIN, "same-origin; foo=bar", false], | ||
]; | ||
|
||
run_coop_tests("unspecified", tests); | ||
|
||
async_test((t) => { | ||
const channelName = `none_to_${SAME_ORIGIN.name}_duplicated-header`; | ||
const url = `${SAME_ORIGIN.origin}/html/cross-origin-opener-policy/resources/coop-same-origin-repeated.asis?channel=${channelName}`; | ||
|
||
url_test(t, url, channelName, true); | ||
}, `unspecified document opening popup to ${SAME_ORIGIN.origin} with repeated COOP header`); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
html/cross-origin-opener-policy/resources/coop-same-origin-repeated.asis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
HTTP/1.1 200 OK | ||
Cross-Origin-Opener-Policy: same-origin | ||
Cross-Origin-Opener-Policy: same-origin | ||
Server: BaseHTTP/0.3 Python/2.7.15+ | ||
Date: Wed, 18 Dec 2019 00:47:08 GMT | ||
|
||
<!doctype html> | ||
<meta charset=utf-8> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<iframe></iframe> | ||
<script> | ||
const navigate = new URL(location).searchParams.get("navigate"); | ||
if (navigate !== null) { | ||
self.location = navigate; | ||
} else { | ||
const iframe = document.querySelector("iframe"); | ||
iframe.onload = () => { | ||
const payload = { name: self.name, opener: !!self.opener }; | ||
iframe.contentWindow.postMessage(payload, "*"); | ||
}; | ||
const channelName = new URL(location).searchParams.get("channel"); | ||
iframe.src = `${get_host_info().HTTPS_ORIGIN}/html/cross-origin-opener-policy/resources/postback.html?channel=${channelName}`; | ||
} | ||
</script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having seen the COEP comments I guess we should address here too what bytes are going to be emitted by the server. And what shortcomings this approach has (in that 0xFF isn't feasible). Perhaps we should change approach so we can effectively specify bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point. I've changed it now for this PR to specify bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check that other users of common.js not rely on encodeURIComponent? Especially reporting tests might be impacted, perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yes, though it's not obvious from test results (chrome, firefox).
But instead of sprinkling
encodeURIComponent
everywhere, I'm thinking about doing it differently, like using an object for the 0xFF test case:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems reasonable, though I'd name it
percentEncoded
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.