<?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>146650</bug_id>
          
          <creation_ts>2015-07-06 12:00:02 -0700</creation_ts>
          <short_desc>Origin not sent on anonymous async JS requests</short_desc>
          <delta_ts>2020-08-28 15:21:14 -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>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>OS X 10.10</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Patrick Toomey">ptoomey3</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>ptoomey3</cc>
    
    <cc>timmfin</cc>
    
    <cc>trevorburnham</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1107175</commentid>
    <comment_count>0</comment_count>
    <who name="Patrick Toomey">ptoomey3</who>
    <bug_when>2015-07-06 12:00:02 -0700</bug_when>
    <thetext>We had some CORS logic that relied on looking at the `Origin` header for setting the appropriate `Access-Control-Allow-Origin` response. The page that relied on this looked something like:

```
&lt;html&gt;
...
&lt;script crossorigin=&quot;anonymous&quot; src=&quot;...&quot;&gt;&lt;/script&gt;
&lt;script async=&quot;async&quot; crossorigin=&quot;anonymous&quot; src=&quot;...&quot;&gt;&lt;/script&gt;
&lt;script async=&quot;async&quot; crossorigin=&quot;anonymous&quot; src=&quot;...&quot;&gt;&lt;/script&gt;
...
&lt;/html&gt;
```

We noticed that only the first JS request included the `Origin` header. The two async requests did not include it. Even more strangely, it seems like the non-async resource acts like some sort of toggle that prevents `Origin` from being added for all future JS resource requests. For example:

```
# The below will send `Origin` for the first request and not for the second and third
&lt;script some-non-async...&gt;
&lt;script async=&quot;async&quot;...&gt;
&lt;script async=&quot;async&quot;...&gt;

# The below will send `Origin` for the first and second request and not the third
&lt;script async=&quot;async&quot;...&gt;
&lt;script some-non-async...&gt;
&lt;script async=&quot;async&quot;...&gt;

# The below will send `Origin` for all the requests
&lt;script async=&quot;async&quot;...&gt;
&lt;script async=&quot;async&quot;...&gt;
&lt;script some-non-async...&gt;
```

This behavior is reproducible on the latest Safari as well as the latest WebKit nightly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1108922</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2015-07-11 06:06:34 -0700</bug_when>
    <thetext>&lt;rdar://problem/21781367&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1109434</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Finley">timmfin</who>
    <bug_when>2015-07-14 13:31:17 -0700</bug_when>
    <thetext>I also just ran into this. I am on Safari Version 7.1.6 (9537.85.15.3)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1109442</commentid>
    <comment_count>3</comment_count>
    <who name="Trevor Burnham">trevorburnham</who>
    <bug_when>2015-07-14 13:43:46 -0700</bug_when>
    <thetext>In addition to the Safari version Tim Finley mentioned, I&apos;ve been able to reproduce this in:

* Version 8.0.7 (10600.7.12)
* Version 6.1 (8537.71)
* Version 6.0.5 (7536.30.1)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1242922</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Finley">timmfin</who>
    <bug_when>2016-10-21 09:39:47 -0700</bug_when>
    <thetext>Note, this seems to be fixed in Safari 10 on Sierra (but still doesn&apos;t work in Safari 9.1 in El Capitan)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1683785</commentid>
    <comment_count>5</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2020-08-28 15:21:14 -0700</bug_when>
    <thetext>Closing based on reporter&apos;s statement about Safari 10.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>