Skip to content

Add tests for how styles fetch resources from the network #31344

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

Merged
merged 3 commits into from
Feb 2, 2022
Merged

Conversation

noamr
Copy link
Contributor

@noamr noamr commented Oct 21, 2021

Ensure that Origin/Referer headers are sent according to specification with different scenarios.

See w3c/csswg-drafts#6715

@wpt-pr-bot
Copy link
Collaborator

There are no reviewers for this pull request. Please reach out on W3C's irc server (irc.w3.org, port 6665) on channel #testing (web client) to get help with this. Thank you!

Copy link
Contributor

@yoavweiss yoavweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % comment on using Fetch-Metadata

Is it worthwhile to cover more image types? (e.g. border images)

const echo = get_resource_echo_url(uid, url)
const style = `
@font-face { font-family: "SomeFont"; src: url(${echo}); }
`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: spurious newline..

promise_test(async t => {
const uid = "{{uuid()}}";
const result = await load_image({uid, url: image_url, prop: 'background'}, t)
assert_false(Reflect.has(result, 'origin'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to use https://www.w3.org/TR/fetch-metadata/#sec-fetch-mode-header to verify that the mode is no-cors. (on top of or instead of origin as a CORS proxy)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to use https://www.w3.org/TR/fetch-metadata/#sec-fetch-mode-header to verify that the mode is no-cors. (on top of or instead of origin as a CORS proxy)

I think Safari doesn't send that though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use them when available as a second layer? They can provide extra info (e.g. for CORS fetches, indicate if it's same-origin, use-credentials or omit)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can perform an equivalent fetch() and see that we sent the same headers

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, although I'm not sure it'd be functionaly different from a "if we have Sec-Fetch-Mode headers, make sure their value is X"

@noamr
Copy link
Contributor Author

noamr commented Oct 28, 2021

LGTM % comment on using Fetch-Metadata

Is it worthwhile to cover more image types? (e.g. border images)

I can add border-image support, sure. Though it shouldn't be any different from background.

@noamr noamr merged commit 271a7f6 into master Feb 2, 2022
@noamr noamr deleted the css-fetch branch February 2, 2022 12:51
mattwoodrow pushed a commit to mattwoodrow/wpt that referenced this pull request Feb 15, 2022
…rm-tests#31344)

* Add tests for how styles fetch resources from the network

* Lint

* Using sec-fetch-mode when available.
Removed referer for now as it's unclear what it should be.
DanielRyanSmith pushed a commit to DanielRyanSmith/wpt that referenced this pull request Feb 28, 2022
…rm-tests#31344)

* Add tests for how styles fetch resources from the network

* Lint

* Using sec-fetch-mode when available.
Removed referer for now as it's unclear what it should be.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants