<?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>249887</bug_id>
          
          <creation_ts>2022-12-25 14:10:39 -0800</creation_ts>
          <short_desc>preloading local file with &quot;crossorigin&quot; leads to the file not being loaded at all</short_desc>
          <delta_ts>2023-08-17 05:36:52 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>Safari 16</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=236009</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>86817</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter>kalle.wachsmuth</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>annevk</cc>
    
    <cc>beidson</cc>
    
    <cc>cdumez</cc>
    
    <cc>mmaxfield</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1921899</commentid>
    <comment_count>0</comment_count>
      <attachid>464209</attachid>
    <who name="">kalle.wachsmuth</who>
    <bug_when>2022-12-25 14:10:39 -0800</bug_when>
    <thetext>Created attachment 464209
example HTML document

Issue encountered here: https://github.com/rust-lang/rust/issues/98769

The problematic preload link looks like this:

&lt;link rel=&quot;preload&quot; as=&quot;font&quot; type=&quot;font/woff2&quot; crossorigin href=&quot;SourceSerif4-Regular.ttf.woff2&quot;&gt;

crossorigin is apparently needed for preloading fonts (https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload#cors-enabled_fetches).
The issue arises when the file to be loaded is on the local machine (file:/// URLs). This doesn&apos;t work in conjunction with crossorigin.
Dev console:

[Error] Origin null is not allowed by Access-Control-Allow-Origin. Status code: 0
[Error] Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. Status code: 0 (SourceSerif4-Regular.ttf.woff2, line 0)

Failing to preload a local file isn&apos;t much of a problem, but attempting to fetch the font later (it&apos;s being pulled in from CSS) will then also fail. As a result, the preload link prevents the font from being loaded at all.

## Reproducing

Safari 16.2 (18614.3.7.1.5) / macOS 13.1 on x86-64

Example font: https://github.com/rust-lang/rust/raw/298d763fc0ac206cf3ae202459101e36a17071f7/src/librustdoc/html/static/fonts/SourceSerif4-Regular.ttf.woff2
Example HTML document is in the attachments
Put them both in the same folder and open the document.

serif font      --&gt; success
sans-serif font --&gt; failure

The same thing works fine in Firefox 108.0.1 for example</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922456</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-01-01 14:11:15 -0800</bug_when>
    <thetext>&lt;rdar://problem/103802172&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922529</commentid>
    <comment_count>2</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-01-02 07:56:00 -0800</bug_when>
    <thetext>It sounds like this is further fallout from us not using CORS for font fetches.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>464209</attachid>
            <date>2022-12-25 14:10:39 -0800</date>
            <delta_ts>2022-12-25 14:10:39 -0800</delta_ts>
            <desc>example HTML document</desc>
            <filename>preload-bug.html</filename>
            <type>text/html</type>
            <size>464</size>
            <attacher>kalle.wachsmuth</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KCTxzdHlsZT4KCQlAZm9udC1mYWNlIHsKCQkJ
Zm9udC1mYW1pbHk6ICJTb3VyY2UgU2VyaWYgNCI7CgkJCWZvbnQtc3R5bGU6IG5vcm1hbDsKCQkJ
Zm9udC13ZWlnaHQ6IDQwMDsKCQkJc3JjOiBsb2NhbCgiU291cmNlIFNlcmlmIDQiKSwgdXJsKCJT
b3VyY2VTZXJpZjQtUmVndWxhci50dGYud29mZjIiKSBmb3JtYXQoIndvZmYyIik7CgkJCWZvbnQt
ZGlzcGxheTogc3dhcDsKCQl9CgoJCWJvZHkgewoJCQlmb250LWZhbWlseTogIlNvdXJjZSBTZXJp
ZiA0Iiwgc2Fucy1zZXJpZjsKCQl9Cgk8L3N0eWxlPgoJPGxpbmsgcmVsPSJwcmVsb2FkIiBhcz0i
Zm9udCIgdHlwZT0iZm9udC93b2ZmMiIgY3Jvc3NvcmlnaW4gaHJlZj0iU291cmNlU2VyaWY0LVJl
Z3VsYXIudHRmLndvZmYyIj4KPC9oZWFkPgo8Ym9keT4KCTxoMT5UZXN0ITwvaDE+CjwvYm9keT4K
PC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>