<?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>247626</bug_id>
          
          <creation_ts>2022-11-08 11:13:07 -0800</creation_ts>
          <short_desc>Unable to render cross-origin image tag when added through fetch and javascript</short_desc>
          <delta_ts>2024-03-21 20:32:19 -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>DOM</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=271377</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar, NeedsReduction</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marcos G.">marcosdg3</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annevk</cc>
    
    <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>karlcow</cc>
    
    <cc>marcosdg3</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1911049</commentid>
    <comment_count>0</comment_count>
    <who name="Marcos G.">marcosdg3</who>
    <bug_when>2022-11-08 11:13:07 -0800</bug_when>
    <thetext>Steps to reproduce:

1) Add event listener on DOMContentLoaded
2) From event handler make fetch to same-site API, resolve promise, and create html from local script:
   &lt;img src=&quot;https://files.collegenet.com/public/standout_prod/default/28RE8QYZ4G/organization-logo?h=standout.com&amp;externalId=9d99a832-17f8-448e-9690-bf07927a7757&quot; crossorigin=&quot;anonymous&quot;&gt; 
3) Append html to dom element.
4) Observe console errors:

&gt; [Error] Cancelled load to https://files.collegenet.com/public/standout_prod/default/28RE8QYZ4G/organization-logo?h=standout.com&amp;externalId=9d99a832-17f8-448e-9690-bf07927a7757 because it violates the resource&apos;s Cross-Origin-Resource-Policy response header.
&gt; [Error] Failed to load resource: Cancelled load to https://files.collegenet.com/public/standout_prod/default/28RE8QYZ4G/organization-logo?h=standout.com&amp;externalId=9d99a832-17f8-448e-9690-bf07927a7757 because it violates the resource&apos;s Cross-Origin-Resource-Policy response header. (organization-logo, line 0)

--------------------------------------------------------------------------------------------------------------

Expected Results: &lt;img&gt; tag renders. 

--------------------------------------------------------------------------------------------------------------

Notes:
* Loads as expected in firefox, chrome, edge
* Rendering the page with the &lt;img&gt; html snippet above (not added by javascript) below works as expected, no CORS error, img tag renders as expected
* Resizing the page sometimes renders the image it blocked earlier
* Example here: https://standout.com/login?email=test%40collegenet.com

--------------------------------------------------------------------------------------------------------------

Summary copied from Safari network tab for the html page request:

Summary
URL: https://standout.com/login?email=test%40collegenet.com
Status: 200
Source: Network
Address: ***

Request
:method: GET
:scheme: https
:authority: standout.com
:path: /login?email=test%40collegenet.com
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Cookie: ***
Host: standout.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15

Response
:status: 200
Accept-Ranges: none
Access-Control-Allow-Credentials: true
Cache-Control: no-store, must-revalidate
Content-Encoding: gzip
Content-Language: en-US
Content-Length: 2432
Content-Security-Policy: default-src &apos;self&apos; &apos;unsafe-inline&apos; &apos;wasm-unsafe-eval&apos; data: blob: https://www.google-analytics.com https://www.googletagmanager.com https://fonts.googleapis.com https://fonts.gstatic.com https://files.collegenet.com
Content-Type: text/html;charset=UTF-8
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-site
Date: Tue, 08 Nov 2022 18:51:31 GMT
Last-Modified: Mon, 31 Oct 2022 22:15:54 GMT
Server: Apache
Set-Cookie: ***
Vary: Origin,Accept-Encoding,Access-Control-Request-Method,Access-Control-Request-Headers
x-content-security-policy: frame-ancestors &apos;self&apos;
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

Query String Parameters
email: test@collegenet.com


--------------------------------------------------------------------------------------------------------------

Summary copied from Safari network tab for the image request:

URL: https://files.collegenet.com/public/standout_prod/default/28RE8QYZ4G/organization-logo?h=standout.com&amp;externalId=9d99a832-17f8-448e-9690-bf07927a7757
Status: 200
Source: Network
Address: ***
Initiator: 
login-bundle-c54d9126d4b8547a6044.js:1:78985


Request
:method: GET
:scheme: https
:authority: files.collegenet.com
:path: /public/standout_prod/default/28RE8QYZ4G/organization-logo?h=standout.com&amp;externalId=9d99a832-17f8-448e-9690-bf07927a7757
Accept: image/webp,video/*;q=0.8,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Host: files.collegenet.com
Origin: https://standout.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15

Response
:status: 200
Accept-Ranges: bytes
Access-Control-Allow-Origin: https://standout.com
Access-Control-Expose-Headers: etag, content-range, accept-ranges, content-length, Content-Type, Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers
Cache-Control: no-cache, private
Content-Disposition: inline; filename=&quot;tmp-organization-img&quot;
Content-Length: 16334
Content-Security-Policy: frame-ancestors &apos;self&apos;
Content-Type: image/png
Date: Tue, 08 Nov 2022 18:51:32 GMT
ETag: &quot;c046aeb8e304de695c735e4056eee55f&quot;
Last-Modified: Wed, 05 Oct 2022 17:57:25 GMT
Server: Apache
Set-Cookie: ***
Vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers
x-content-security-policy: frame-ancestors &apos;self&apos;
x-fs-downloadimpl: 2.0

Query String Parameters
h: standout.com
externalId: 9d99a832-17f8-448e-9690-bf07927a7757</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1911163</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2022-11-08 19:41:26 -0800</bug_when>
    <thetext>AFAICT the image should be allowed to load - the document has `Cross-Origin-Embedder-Policy: require-corp`, but the image has `Access-Control-Allow-Origin: https://standout.com`.

&gt; * Resizing the page sometimes renders the image it blocked earlier

Yes, relayout makes it show up. Cmd+ is a good way to see this too.

This makes me wonder if have two unrelated bugs:

1. COEP produces a misleading error, even though it doesn&apos;t actually prevent loading.

2. A layout bug that makes the image not appear until relayout.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1911399</commentid>
    <comment_count>2</comment_count>
    <who name="Marcos G.">marcosdg3</who>
    <bug_when>2022-11-09 16:35:07 -0800</bug_when>
    <thetext>Thanks for your comment Alexey, created a temp fix by forcing a relayout.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1911494</commentid>
    <comment_count>3</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2022-11-10 02:44:33 -0800</bug_when>
    <thetext>Yeah this is weird. The crossorigin attribute makes this a request whose mode is &quot;cors&quot; at which point CORP (or COEP) doesn&apos;t apply. Those only impact &quot;no-cors&quot; and to a limited extent &quot;navigate&quot;. And since per ap&apos;s comment CORS is in order the network layer shouldn&apos;t complain about anything here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912668</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-11-15 11:14:17 -0800</bug_when>
    <thetext>&lt;rdar://problem/102377924&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>