Description
Spec https://drafts.csswg.org/css-cascade/#content-type
The processing of imported style sheets depends on the actual type of the linked resource. If the resource does not have Content-Type metadata, or the host document is in quirks mode and has the same origin as the imported style sheet, the type of the linked resource is text/css. Otherwise, the type is determined from its Content-Type metadata.
If the linked resource’s type is text/css, it must be interpreted as a CSS style sheet. Otherwise, it must be interpreted as a network error.
The HTML spec says for <link rel=stylesheet>
:
Quirk: If the document has been set to quirks mode, has the same origin as the URL of the external resource, and the Content-Type metadata of the external resource is not a supported style sheet type, the user agent must instead assume it to be text/css.
https://html.spec.whatwg.org/multipage/links.html#link-type-stylesheet
I said the following on Twitter https://twitter.com/zcorpan/status/1235724741224226816
Does something say that stylesheets can have an origin? HTML doesn't. https://html.spec.whatwg.org/multipage/origin.html#concept-origin
Which origins should be compared? The imported URL's origin with the host document's origin? The imported URL's origin with the current stylesheet's URL's? (Before or after redirects?)
Reading the @import
spec again I think it's clear that it's comparing the host document's origin. But the other origin is less clear, since the origin of "the imported style sheet" is not defined, as far as I know.
(The question about before or after redirects might also apply to HTML.)