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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26735</bug_id>
          
          <creation_ts>2014-09-05 13:01:15 +0000</creation_ts>
          <short_desc>Reject opaque ServiceWorker responses if the original request has a mode of CORS</short_desc>
          <delta_ts>2014-09-09 11:11:06 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>Fetch</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jake Archibald">jaffathecake</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>mike</cc>
    
    <cc>tyoshino</cc>
          
          <qa_contact>sideshowbarker+fetchspec</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>111061</commentid>
    <comment_count>0</comment_count>
    <who name="Jake Archibald">jaffathecake</who>
    <bug_when>2014-09-05 13:01:15 +0000</bug_when>
    <thetext>…or CORS-with-forced-preflight.

These should be treated as network failures.

This caters for opaque responses being given for XHR, &lt;img crossorigin&gt; etc.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111125</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-09-06 09:47:02 +0000</bug_when>
    <thetext>So in http://fetch.spec.whatwg.org/#http-fetch we need to make step 2 more elaborate.

2. If request&apos;s skip service worker flag is unset and request&apos;s client is not a service worker environment, run these substeps: [HTML]

2.1. Set response to the result of invoking handle a fetch for request. [SW]

2.2. If either /response/&apos;s type is opaque and request&apos;s mode is not /no CORS/ or /response/&apos;s type is error, return a network error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111234</commentid>
    <comment_count>2</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2014-09-09 05:23:25 +0000</bug_when>
    <thetext>Looks good.

Curious if this is a security issue or just about consistency.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111237</commentid>
    <comment_count>3</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2014-09-09 07:57:21 +0000</bug_when>
    <thetext>I asked horo@ about what opaque intended to mean for img and XHR. Now I understand the background.

It seems ideally we should just have the customer specs of the fetch to pass their privilege (XHR cannot read opaque. img can read opaque, etc.) and the fetch returns filtered data based on the privilege than allowing the customer specs to read &quot;internal response&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111239</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-09-09 09:02:54 +0000</bug_when>
    <thetext>(In reply to Takeshi Yoshino from comment #3)
&gt; It seems ideally we should just have the customer specs of the fetch to pass
&gt; their privilege (XHR cannot read opaque. img can read opaque, etc.) and the
&gt; fetch returns filtered data based on the privilege than allowing the
&gt; customer specs to read &quot;internal response&quot;.

Isn&apos;t that what we are doing here? Only if &lt;img&gt; asks for /no CORS/ can get it get an opaque response from which it needs to obtain an internal response.

XMLHttpRequest never asks for /no CORS/ and therefore never gets an opaque response.

If that is not what you meant, could you explain what kind of model you would expect?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111248</commentid>
    <comment_count>5</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2014-09-09 09:56:57 +0000</bug_when>
    <thetext>(In reply to Anne from comment #4)
&gt; (In reply to Takeshi Yoshino from comment #3)
&gt; &gt; It seems ideally we should just have the customer specs of the fetch to pass
&gt; &gt; their privilege (XHR cannot read opaque. img can read opaque, etc.) and the
&gt; &gt; fetch returns filtered data based on the privilege than allowing the
&gt; &gt; customer specs to read &quot;internal response&quot;.
&gt; 
&gt; Isn&apos;t that what we are doing here? Only if &lt;img&gt; asks for /no CORS/ can get
&gt; it get an opaque response from which it needs to obtain an internal response.

Ah, I see. The opaque feature is for hiding data of a response from JS code in SW. To do so, you tried to keep the algorithm between the response concept and the Response object. Instead of adding type==opaque check in the accessors of the Response object, you chose to have the internal response and make it available for &lt;img&gt;, etc. Right? It makes sense.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111249</commentid>
    <comment_count>6</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2014-09-09 09:57:56 +0000</bug_when>
    <thetext>(In reply to Takeshi Yoshino from comment #5)
&gt; Ah, I see. The opaque feature is for hiding data of a response from JS code
&gt; in SW. To do so, you tried to keep the algorithm between the response
&gt; concept and the Response object. Instead of adding type==opaque check in the

s/Response object/Response object simple/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111251</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-09-09 10:20:50 +0000</bug_when>
    <thetext>Yeah, that&apos;s the idea.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111256</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-09-09 11:11:06 +0000</bug_when>
    <thetext>https://github.com/whatwg/fetch/commit/f5ecd97e4956a93f521f179332aa1c2569b092c9</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>