<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>261811</bug_id>
          
          <creation_ts>2023-09-20 03:01:46 -0700</creation_ts>
          <short_desc>Link-stylesheet elements fire load events for non-text/css and non-2XX responses</short_desc>
          <delta_ts>2024-03-06 15:44:23 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/web-platform-tests/wpt/pull/42147</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>jannis.rautenstrauch</reporter>
          <assigned_to name="sideshowbarker">mike</assigned_to>
          <cc>annevk</cc>
    
    <cc>cdumez</cc>
    
    <cc>heycam</cc>
    
    <cc>karlcow</cc>
    
    <cc>koivisto</cc>
    
    <cc>mike</cc>
    
    <cc>twisniewski</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1978607</commentid>
    <comment_count>0</comment_count>
    <who name="">jannis.rautenstrauch</who>
    <bug_when>2023-09-20 03:01:46 -0700</bug_when>
    <thetext>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&amp;ecohd_status=302)
WebKit load, Firefox error</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979370</commentid>
    <comment_count>1</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-09-22 09:36:03 -0700</bug_when>
    <thetext>Chrome seems to match the WebKit behavior in both cases, right? That is, Chrome loads both stylesheets, without any errors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979560</commentid>
    <comment_count>2</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-09-23 08:05:46 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/18122</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979561</commentid>
    <comment_count>3</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-09-23 08:20:14 -0700</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979697</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-09-24 16:46:39 -0700</bug_when>
    <thetext>&gt; 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979712</commentid>
    <comment_count>5</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-09-24 19:12:53 -0700</bug_when>
    <thetext>&gt; &gt; 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.
&gt; 
&gt; This should probably be a separate bug too.

Agreed yeah — Jannis, could you please raise a separate bug for the 3XX/non-2XX case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979720</commentid>
    <comment_count>6</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-09-24 21:16:51 -0700</bug_when>
    <thetext>Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/42147</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1979742</commentid>
    <comment_count>7</comment_count>
    <who name="">jannis.rautenstrauch</who>
    <bug_when>2023-09-25 00:27:33 -0700</bug_when>
    <thetext>I created another bug report here: https://bugs.webkit.org/show_bug.cgi?id=262030

Here are testcases for 200 with bodies:
- text/html + css body: https://observer.sectec.rocks/opg/link-stylesheet/?url=https://echo.sectec.rocks/echo/?content-type=text/html&amp;ecocnt_css=p%20{color:%20red;} -&gt; error in WebKit and Firefox, Load in Chromium
- text/html + image body: https://observer.sectec.rocks/opg/link-stylesheet/?url=https://echo.sectec.rocks/echo/?content-type=text/html&amp;ecocnt_img=width=200,height=300,type=png -&gt; error in WebKit and Firefox, Load in Chromium
- no content-type + image body: https://observer.sectec.rocks/opg/link-stylesheet/?url=https://echo.sectec.rocks/echo/?ecocnt_img=width=200,height=300,type=png -&gt; load in all browsers</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1980453</commentid>
    <comment_count>8</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-09-27 03:02:27 -0700</bug_when>
    <thetext>&lt;rdar://problem/116112223&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1980626</commentid>
    <comment_count>9</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-09-27 14:10:02 -0700</bug_when>
    <thetext>Committed 268535@main (c31f4e6a298d): &lt;https://commits.webkit.org/268535@main&gt;

Reviewed commits have been landed. Closing PR #18122 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2019098</commentid>
    <comment_count>10</comment_count>
    <who name="Thomas Wisniewski [:twisniewski]">twisniewski</who>
    <bug_when>2024-03-06 10:25:52 -0800</bug_when>
    <thetext>It looks like the WPT pull request was never merged. Could you please check if it&apos;s still good to merge and do so? It would be nice to have this test up on wpt.live and wpt.fyi.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2019210</commentid>
    <comment_count>11</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-03-06 15:44:23 -0800</bug_when>
    <thetext>Thanks Thomas for the heads up.
This has been done.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>