RESOLVED FIXED261811
Link-stylesheet elements fire load events for non-text/css and non-2XX responses
https://bugs.webkit.org/show_bug.cgi?id=261811
Summary Link-stylesheet elements fire load events for non-text/css and non-2XX responses
jannis.rautenstrauch
Reported 2023-09-20 03:01:46 PDT
If I understand https://html.spec.whatwg.org/#link-type-stylesheet correctly, cross-origin responses should only result in a load for codes 2XX and content-type text/css. If my understanding is false, there still is a compatibility problem as Firefox (and Chromium) behave different for various responses. Example differences: - 200 with content-type text/html (https://observer.sectec.rocks/opg/link-stylesheet/?url=https://echo.sectec.rocks/echo/?content-type=text/html) WebKit load, Firefox error - 3XX with content-type text/css and no location header (https://observer.sectec.rocks/opg/link-stylesheet/?url=https://echo.sectec.rocks/echo/?content-type=text/css&ecohd_status=302) WebKit load, Firefox error
Attachments
sideshowbarker
Comment 1 2023-09-22 09:36:03 PDT
Chrome seems to match the WebKit behavior in both cases, right? That is, Chrome loads both stylesheets, without any errors.
sideshowbarker
Comment 2 2023-09-23 08:05:46 PDT
sideshowbarker
Comment 3 2023-09-23 08:20:14 PDT
About the “200 with content-type text/html” case: Testing and code inspection show that WebKit doesn’t actually process that https://echo.sectec.rocks/echo/?content-type=text/html resource — it’s just that currently (due to the order of a particular condition in the code), the reason WebKit doesn’t process it is that the resource is empty (has no HTTP body/data). But I guess, for developer ergonomics, it’s arguably better to still log a console message even when the resource is empty — so I opened https://github.com/WebKit/WebKit/pull/18122 with a patch which does that. I haven’t investigated the “3XX with content-type text/css and no location header” case yet, but it seems likely that the behavior there may also be due to the fact the resource is empty. I can look into it later, but in the meantime you might want to put together an additional test which serves a non-empty resource for that case — and see if you get different behavior.
Karl Dubost
Comment 4 2023-09-24 16:46:39 PDT
> I haven’t investigated the “3XX with content-type text/css and no location header” case yet, but it seems likely that the behavior there may also be due to the fact the resource is empty. I can look into it later, but in the meantime you might want to put together an additional test which serves a non-empty resource for that case — and see if you get different behavior. This should probably be a separate bug too.
sideshowbarker
Comment 5 2023-09-24 19:12:53 PDT
> > I haven’t investigated the “3XX with content-type text/css and no location header” case yet, but it seems likely that the behavior there may also be due to the fact the resource is empty. > > This should probably be a separate bug too. Agreed yeah — Jannis, could you please raise a separate bug for the 3XX/non-2XX case?
sideshowbarker
Comment 6 2023-09-24 21:16:51 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/42147
jannis.rautenstrauch
Comment 7 2023-09-25 00:27:33 PDT
Radar WebKit Bug Importer
Comment 8 2023-09-27 03:02:27 PDT
EWS
Comment 9 2023-09-27 14:10:02 PDT
Committed 268535@main (c31f4e6a298d): <https://commits.webkit.org/268535@main> Reviewed commits have been landed. Closing PR #18122 and removing active labels.
Thomas Wisniewski [:twisniewski]
Comment 10 2024-03-06 10:25:52 PST
It looks like the WPT pull request was never merged. Could you please check if it's still good to merge and do so? It would be nice to have this test up on wpt.live and wpt.fyi.
Karl Dubost
Comment 11 2024-03-06 15:44:23 PST
Thanks Thomas for the heads up. This has been done.
Note You need to log in before you can comment on or make changes to this bug.