<?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>26247</bug_id>
          
          <creation_ts>2014-07-01 08:59:18 +0000</creation_ts>
          <short_desc>Request contexts.</short_desc>
          <delta_ts>2014-07-29 12:30:34 +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>Linux</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="Mike West">mkwst</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>mike</cc>
    
    <cc>w3c</cc>
          
          <qa_contact>sideshowbarker+fetchspec</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>108576</commentid>
    <comment_count>0</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-01 08:59:18 +0000</bug_when>
    <thetext>I&apos;m sifting through Blink&apos;s innards to align what requests types we use with what the spec says we should care about. There are some differences; we should resolve them.

Currently, Blink/Chromium use two different enums for different purposes (historical artifact from WebKit days; Chromium and Safari had different needs):

Resource::Type: https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/core/fetch/Resource.h&amp;l=61

ResourceRequest::TargetType: https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/platform/network/ResourceRequest.h&amp;l=55

Most of these map nicely to one of the request contexts defined in Fetch. Some don&apos;t.

Specifically, I&apos;m looking at:

* `Resource::LinkSubresource`/`ResourceRequest::TargetIsSubresource` (which we use to set download priorities of things like `&lt;link rel=&quot;subresource&quot;&gt;`, distinct from `&lt;link rel=&quot;prefetch&quot;&gt;`.

* `Resource::Raw` which, among other things, carries requests from PPAPI plugins like Flash.

* `Resource::TextTrack`: I think we can fold this into `Resource::Media`, but it looks like there&apos;s some special-casing of behavior in Chromium that&apos;s not done yet, so I&apos;m not sure why it&apos;s there. :)

* `Resource::Favicon`: Again, this sets priority, and tells Chromium to set some flags which ignore login requests.

On the one hand, I want as much detail as possible so I can granularly turn off mixed content for specific types as usage data allows. On the other, I don&apos;t want Fetch to have to know about EVERYTHING EVER OMG.

Where do you think the balance lies?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108577</commentid>
    <comment_count>1</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-01 09:04:16 +0000</bug_when>
    <thetext>* `Request::ImportResource` for HTML Imports, which Blink currently blocks as active content. I suppose we could map this to the &apos;script&apos; context?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108584</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-01 09:20:43 +0000</bug_when>
    <thetext>I am totally fine with adding more contexts and having all the granularity forever. Contexts are very cheap and it&apos;s good to have an overview of what kind of fetching is out there.

I&apos;m not sure how I feel about contexts being responsible for setting other bits on the request field. E.g. if you care about authentication you need to set the &quot;authentication flag&quot; (by default unset as the whole prompting thing there is bad UI).

Now on the other hand I have been thinking about contexts being responsible for setting headers in http://fetch.spec.whatwg.org/#concept-http-network-or-cache-fetch (e.g. setting Accept to a particular value) so maybe that is not such a bad idea?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108587</commentid>
    <comment_count>3</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-01 09:32:38 +0000</bug_when>
    <thetext>For the moment, I think I&apos;d suggest something like the following:

* Rename `navigate` to `mainFrame` (are there any other types of navigation?)
* Rename `child` to `childFrame` (since you&apos;ve already split workers out)
* Split `media` into `audio`, `video`, and `textTrack`.
* Add `favicon`.
* Add `subresource`.
* Add `objectRequest` (as distinct from `object`).

But let&apos;s keep this open while I&apos;m working on the refactoring patches. It&apos;s not yet clear to me which of the request types are purely historical, and which have actual impact on the way the Blink or Chromium&apos;s network stack makes requests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108590</commentid>
    <comment_count>4</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-01 09:44:19 +0000</bug_when>
    <thetext>Do you happen to know the right folks to poke on Mozilla&apos;s side? It&apos;d be nice if we aligned our expectations regarding what&apos;s actually needed for UAs to do the things they&apos;re currently doing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108595</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-01 10:00:34 +0000</bug_when>
    <thetext>toplevelbrowsingcontext and browsingcontext would be better. Although maybe we should use topframe and frame given that CSP has frame-ancestor as term already? topdocument / document could also work.

What is objectRequest?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108597</commentid>
    <comment_count>6</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-01 10:09:25 +0000</bug_when>
    <thetext>(In reply to Anne from comment #5)
&gt; toplevelbrowsingcontext and browsingcontext would be better. Although maybe
&gt; we should use topframe and frame given that CSP has frame-ancestor as term
&gt; already? topdocument / document could also work.

Up to you, I don&apos;t really care how we spell bikeshed. :)

&gt; What is objectRequest?

Requests made by plugins (which we sometimes see in Chromium/Blink, and sometimes don&apos;t: hooray for plugins).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108599</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-01 10:14:24 +0000</bug_when>
    <thetext>https://groups.google.com/d/msg/mozilla.dev.platform/4Cfqd1yLkjY/8L8FOuatB7EJ re asking others at Mozilla.

Re plugins, makes sense. Not sure about the name, might bikeshed.

What about &lt;object&gt;? We don&apos;t really know whether it ends up creating a browsing context or will just display an image before we get the response. It causes problems for service workers as well (should this request be associated with a new service worker or the current one, in particular).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108601</commentid>
    <comment_count>8</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-01 10:51:26 +0000</bug_when>
    <thetext>(In reply to Anne from comment #7)
&gt; What about &lt;object&gt;? We don&apos;t really know whether it ends up creating a
&gt; browsing context or will just display an image before we get the response.
&gt; It causes problems for service workers as well (should this request be
&gt; associated with a new service worker or the current one, in particular).

We &quot;solve&quot; that in CSP by not caring: if it&apos;s loaded via `&lt;object&gt;`, it&apos;s controlled by &apos;object-src&apos;, regardless of what it turns out to be.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108639</commentid>
    <comment_count>9</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-02 10:31:27 +0000</bug_when>
    <thetext>Per the thread linked in comment 7 it seems we need to add these to the list from comment 3:

* xslt (&lt;?xsl-stylesheet?&gt; I presume and perhaps the JavaScript API?)
* cspreport

Should we have separate contexts for &lt;a ping&gt; and sendBeacon()?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108640</commentid>
    <comment_count>10</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-02 10:36:03 +0000</bug_when>
    <thetext>(In reply to Anne from comment #9)
&gt; * xslt (&lt;?xsl-stylesheet?&gt; I presume and perhaps the JavaScript API?)

Chromium folds this into `style`, but adding granularity is fine.

&gt; * cspreport

Chromium folds this into `ping`, but adding granularity is fine.

&gt; Should we have separate contexts for &lt;a ping&gt; and sendBeacon()?

If you&apos;d like to be totally granular, sure.

If we&apos;re going that route, we should split `connect` into `xhr`, `eventsource`, and `websocket`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108641</commentid>
    <comment_count>11</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-02 10:41:17 +0000</bug_when>
    <thetext>I&apos;m not really sure what I want yet :-) But given that XSLT can execute script, it should probably not be style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108642</commentid>
    <comment_count>12</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-02 10:51:39 +0000</bug_when>
    <thetext>(In reply to Anne from comment #11)
&gt; I&apos;m not really sure what I want yet :-) But given that XSLT can execute
&gt; script, it should probably not be style.

Sorry, you&apos;re entirely correct. I wrote &apos;style&apos; but I meant &apos;script&apos;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108643</commentid>
    <comment_count>13</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-02 10:52:32 +0000</bug_when>
    <thetext>(In reply to Anne from comment #11)
&gt; I&apos;m not really sure what I want yet :-)

The more I think about it, the more I&apos;d suggest erring on the side of too much detail. If we&apos;re going to have a list of request types, then we ought to be sure it&apos;s exhaustive.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108728</commentid>
    <comment_count>14</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-04 16:26:25 +0000</bug_when>
    <thetext>I fixed this bug I think except for the websocket suggestion. Maybe there&apos;s something I don&apos;t understand about WebSocket, but this is the second time someone suggested it should be grouped into Fetch, whereas I think it&apos;s mostly its own platform. (Except for grabbing the cookies somehow.)

If you think it should be covered here rather than by WebSocket directly, please file a new bug.


https://github.com/whatwg/fetch/commit/3ce8a2131e8cfa75446e5d24b682413039394f34

Commit summary follows.

I ended up adding these:

* subresource
* plugin (::Raw)
* track (::TextTrack)
* audio
* video
* favicon
* eventsource
* xmlhttprequest
* fetch

And removing:

* connect
* media

Per feedback from comment 7 from Mozilla I added:

* beacon
* cspreport
* xslt

Per feedback from https://github.com/slightlyoff/ServiceWorker/issues/352 I added a new field &quot;context frame type&quot; as well as these contexts:

* hyperlink
* frame
* iframe
* embed
* location

And removed these as a result of that GitHub thread:

* child
* navigate
* popup</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108840</commentid>
    <comment_count>15</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-10 09:29:29 +0000</bug_when>
    <thetext>A few things I&apos;ve seen while poking at Blink:

1. Navigations (and potentially requests) can happen based on user input to the UA, rather than clicking a link (back button, reload button, etc). I don&apos;t know how these are modeled in Gecko, but in Blink, they show up as Fetches (which are resolved by the cache).

2. Requests from devtools, and other &quot;internal&quot; bits and pieces pass through the fetching mechanisms in Blink.

Based on this, I&apos;d suggest adding an &quot;internal&quot; request type. Happy to throw that in a separate bug if that makes more sense. Otherwise I&apos;d just reopen this one.

Also: I&apos;m finding a lot of Blink code that relied on conflating the initiator of a request (&quot;hyperlink&quot;) and the target of the request (&quot;iframe&quot; vs &quot;main&quot;). Adding a context frame type will help clear this up. Thanks for that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108901</commentid>
    <comment_count>16</comment_count>
    <who name="Mike West">mkwst</who>
    <bug_when>2014-07-14 07:51:15 +0000</bug_when>
    <thetext>And HTML Imports. I&apos;m throwing those into &apos;script&apos; for the moment (which might be reasonable in general?).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109489</commentid>
    <comment_count>17</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-29 12:30:34 +0000</bug_when>
    <thetext>https://github.com/whatwg/fetch/commit/2cc41cf2d0872bc87a849e1faaa7cec1633aea39

Let&apos;s do new bugs for any new things that come up. Thanks for all the help so far!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>