-
Notifications
You must be signed in to change notification settings - Fork 31
Fonts and crossorigin #32
Comments
I don't think we can omit As for fonts getting special treatment.. this seems like a bit too much magic. I think it may be even more confusing for fonts to transparently opt-in into this mode, whereas you'd have to still specify the crossorigin attribute for other use cases. |
Yeah, I wasn't suggesting that we omit
I agree it's magical, but that's already what fonts do... OTOH, I can live with users having to explicitly set So, if we go that route, we need to change the |
@annevk what happens when I'm self-hosting the font on same origin as the document? Do we force the same flag and cause the UA to open a separate connection? (That would be unfortunate) Put another way, are there ever cases where fonts are exempt from forcing |
I think "anonymous" in implementations means that the credentials mode is "same-origin", but someone would have to verify that to be sure. |
I believe that is the case for Chrome.. /cc @mikewest for a sanity check. @yoavweiss the examples in the spec are all same-origin so I don't think it's strictly necessary to add it? That said, perhaps we should change one of the examples to use a different origin with |
I think that's correct, yes. I also don't think we should special case |
Fair enough. In that case, let's just add a different origin example for a font that includes a |
I believe there's some disagreement between the Blink implementation and the spec examples, which we need to sort out. Currently, Blink's implementation requires the An IRC conversation with @annevk made me believe that Blink's implementation is right to do so, but re-reading that, I may have asked the wrong question. Looking at the fonts spec, it fetches fonts with potentially CORS-enabled fetch, which AFAICT would result in "same-origin" fetch for the same-origin case. OTOH, the fetch spec is supposed to supplant the above behavior, but I'm not sure where is that behavior defined. So, should the preload of fonts from the same origin use the |
If the URL is same-origin the |
Can you elaborate on that?
|
CSS doesn't define its integration with Fetch, but Fetch' mode doesn't depend on the URL. (I think that if there are no cross-origin redirects, "cors" and "same-origin" are equivalent for a same-origin URL.) |
Hmm... doesn't the possibility of a redirect force us to treat them as different? As in, I give you a same-origin URL and mark it as Also, as far as I understand, one of the motivations behind |
Cookies are included for same-origin requests, unless you specify "omit" for credentials mode, which almost nothing can do ( |
@igrigorik - seems like both Chrome and Firefox send cookies on same origin font fetches. Regarding the redirect scenario, cross-origin redirects should be CORS, but I don't think it means (or should mean) that non-redirect responses to same-origin requests should not match, nor that same-origin font requests can't use the general socket pool. Adding @sleevi for Opinions™
@annevk - Is that defined in Fetch? Also, is "potentially CORS-enabled fetch" defined? |
I think it follows from what Fetch defines, yes. "potentially CORS-enabled fetch" is no longer a thing. It used to be a thing in the HTML standard, but we removed that some months back. It seems however y'all are quite confused. The socket pool is effectively keyed on origin/credentials. The key for a same-origin fetch will be the origin/true and for a cross-origin fetch will be the origin/false (since the credentials mode for fonts is "same-origin" and the mode will always be "cors"). |
Having read this thread several times since @yoavweiss reached out, I'm still quite confused as to what "the issue" is. But so far everything @annevk has said sounds right. |
OK, let me try to clarify. The issue is me trying to figure out if this is a bug, or if this is the expected behavior and the spec examples should be modified accordingly. |
Why? Well… That’s a long story. A good summary can be found here: w3c/preload#32 (comment)
For some reason, Chrome will download the preloaded fonts, and then ignore them and re-download them _again_. Other browsers don't do this -- only Chrome. If you want to read up on this super weird behaviour: - w3c/preload#32 (comment) - https://bugs.chromium.org/p/chromium/issues/detail?id=584198 - https://stackoverflow.com/a/36508361/9728185 And there's a good example in the MDN docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link
For some reason, Chrome will download the preloaded fonts, and then ignore them and re-download them _again_. Other browsers don't do this -- only Chrome. If you want to read up on this super weird behaviour: - w3c/preload#32 (comment) - https://bugs.chromium.org/p/chromium/issues/detail?id=584198 - https://stackoverflow.com/a/36508361/9728185 And there's a good example in the MDN docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link
If I'm reading obtain the preload resource properly, it'd mean that if a user want to preload a font, they would have to add a
crossorigin
attribute to the<link>
.I wonder if that the best way to go, or we should special case
font
to implicitly setcrossorigin
.I tend to think special casing
font
would be better, since users won't have to worry about that. I worry that otherwise, omittingcrossorigin
and double-downloading the font would be a common error.In any case, we should address this in the spec: Either change the processing model, or change the examples and add a note.
The text was updated successfully, but these errors were encountered: