Skip to content

Commit

Permalink
Make script fetching more correct with regard to request destinations
Browse files Browse the repository at this point in the history
- Previously, "fetch a classic worker script" took a boolean "is
  shared". This generalizes poorly to service workers, so now it takes
  a destination.
- Previously, fetching modules always set a request destination of
  "subresource". Now, "fetch a module script tree" takes a destination
  argument, which is threaded through to all modules fetched in the
  tree, and all its callers (viz. <script> preparation, worker creation,
  and shared worker creation) pass the proper destination value.
- Previously, "fetch a classic script" did not set a destination at all.
  Now it correctly sets "script".

Some other minor changes in related areas:

- Previously, "run a worker" took a boolean "is shared". This was not
  necessary, as it could be inferred from other arguments; it's been
  removed.
- Removed a useless and presumably leftover step from "fetch a classic
  script".
  • Loading branch information
domenic committed Feb 26, 2016
1 parent 5239b84 commit a63c9de
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -58000,7 +58000,7 @@ o............A....e
</li>

<li><p><span>Fetch a module script tree</span> given <var>url</var>, <var>credentials
mode</var>, and <var>settings</var>.</p></li>
mode</var>, "<code data-x="">script</code>", and <var>settings</var>.</p></li>
</ol>
</dd>
</dl>
Expand Down Expand Up @@ -84185,15 +84185,13 @@ interface <dfn>NavigatorOnLine</dfn> {
setting</var>.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-client">client</span> to
<var>settings object</var>, and its <span data-x="concept-request-type">type</span> to "<code
data-x="">script</code>".</p></li>
<var>settings object</var>, its <span data-x="concept-request-type">type</span> to "<code
data-x="">script</code>", and its <span data-x="concept-request-destination">destination</span>
to "<code data-x="">script</code>".</p></li>

<!--FETCH-->
<li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>

<li><p>Let <var>url</var> be a copy of the <span data-x="the document's address">address</span>
of the <code>Document</code> with which <var>window</var> is associated.</p></li>

<li>
<p>Return from this algorithm, and run the remaining steps as part of the fetch's
<span>process response</span> for the <span data-x="concept-response">response</span>
Expand Down Expand Up @@ -84234,22 +84232,20 @@ interface <dfn>NavigatorOnLine</dfn> {
</ol>

<p>To <dfn>fetch a classic worker script</dfn> given a <var>url</var>, a <var>referrer</var>, a
<var>settings object</var>, and a boolean <var>is shared</var>, run these steps. The algorithm
will asynchronously complete with either null (on failure) or a new <span>classic script</span>
(on success).</p>
<var>settings object</var>, and a <var>destination</var>, run these steps. The algorithm will
asynchronously complete with either null (on failure) or a new <span>classic script</span> (on
success).</p>

<ol>
<li><p>Let <var>request</var> be a new <span data-x="concept-request">request</span> whose
<span data-x="concept-request-url">url</span> is <var>url</var>, <span
data-x="concept-request-client">client</span> is <var>settings object</var>, <span
data-x="concept-request-type">type</span> is "<code data-x="">script</code>", <span
data-x="concept-request-destination">destination</span> is "<code
data-x="">sharedworker</code>" if <var>is shared</var> is true and "<code
data-x="">worker</code>" otherwise, <span data-x="concept-request-referrer">referrer</span> is
<var>referrer</var>, <span data-x="concept-request-mode">mode</span> is "<code
data-x="">same-origin</code>", <span data-x="concept-request-credentials-mode">credentials
mode</span> is "<code data-x="">same-origin</code>", and whose <span>use-URL-credentials
flag</span> is set.</p></li>
data-x="concept-request-destination">destination</span> is <var>destination</var>, <span
data-x="concept-request-referrer">referrer</span> is <var>referrer</var>, <span
data-x="concept-request-mode">mode</span> is "<code data-x="">same-origin</code>", <span
data-x="concept-request-credentials-mode">credentials mode</span> is "<code
data-x="">same-origin</code>", and whose <span>use-URL-credentials flag</span> is set.</p></li>

<!--FETCH-->
<li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
Expand All @@ -84273,15 +84269,15 @@ interface <dfn>NavigatorOnLine</dfn> {
</ol>

<p>To <dfn>fetch a module script tree</dfn> given a <var>url</var>, a <var>credentials mode</var>,
a <var>settings object</var>, and an optional <var>ancestor list</var>, run these steps. The
algorithm will asynchronously complete with either null (on failure) or a <span>module
script</span> (on success).</p>
a <var>destination</var>, a <var>settings object</var>, and an optional <var>ancestor list</var>,
run these steps. The algorithm will asynchronously complete with either null (on failure) or a
<span>module script</span> (on success).</p>

<ol>
<li><p>If <var>ancestor list</var> is not given, let it be an empty list.</p></li>

<li><p><span>Fetch a single module script</span> given <var>url</var>, <var>credentials
mode</var>, and <var>settings object</var>.</p>
mode</var>, <var>destination</var>, and <var>settings object</var>.</p>

<li><p>Return from this algorithm and run the following steps when <span data-x="fetch a single
module script">fetching a single module script</span> asynchronously completes with
Expand All @@ -84291,17 +84287,19 @@ interface <dfn>NavigatorOnLine</dfn> {
these steps.</p></li>

<li><p>Otherwise, <var>result</var> is a <span>module script</span>. <span data-x="fetch the
descendants of a module script">Fetch the descendants</span> of <var>result</var> using an
ancestor list obtained by appending <var>url</var> to <var>ancestor list</var>.</p></li>
descendants of a module script">Fetch the descendants</span> of <var>result</var> given
<var>destination</var> and an ancestor list obtained by appending <var>url</var> to <var>ancestor
list</var>.</p></li>

<li><p>When <span data-x="fetch the descendants of a module script">fetching the descendants of
a module script</span> asynchronously completes with <var>descendants result</var>,
asynchronously complete this algorithm with <var>descendants result</var>.</p></li>
</ol>

<p>To <dfn>fetch the descendants of a module script</dfn> <var>module script</var>, using a given
<var>ancestor list</var>, run these steps. The algorithm will asynchronously complete with either
null (on failure) or with <var>module script</var> (on success).</p>
<p>To <dfn>fetch the descendants of a module script</dfn> <var>module script</var>, given a
<var>destination</var> and an <var>ancestor list</var>, run these steps. The algorithm will
asynchronously complete with either null (on failure) or with <var>module script</var> (on
success).</p>

<ol>
<li><p>Let <var>record</var> be <var>module script</var>'s <span
Expand Down Expand Up @@ -84340,8 +84338,8 @@ interface <dfn>NavigatorOnLine</dfn> {
<li>
<p>For each <var>url</var> in <var>urls</var>, <span>fetch a module script tree</span> given
<var>url</var>, <var>module script</var>'s <span
data-x="concept-module-script-credentials-mode">credentials mode</span>, <var>module
script</var>'s <span>settings object</span>, and <var>ancestor list</var>.</p>
data-x="concept-module-script-credentials-mode">credentials mode</span>, <var>destination</var>,
<var>module script</var>'s <span>settings object</span>, and <var>ancestor list</var>.</p>

<p>If any of the <span>fetch a module script tree</span> invocations asynchronously complete
with null, the user agent may <span data-x="concept-fetch-terminate">terminate</span> any or
Expand All @@ -84354,8 +84352,9 @@ interface <dfn>NavigatorOnLine</dfn> {
</ol>

<p>To <dfn>fetch a single module script</dfn>, given a <var>url</var>, a <var>credentials
mode</var>, and a <var>settings object</var>, run these steps. The algorithm will asynchronously
complete with either null (on failure) or a <span>module script</span> (on success).</p>
mode</var>, a <var>destination</var>, and a <var>settings object</var>, run these steps. The
algorithm will asynchronously complete with either null (on failure) or a <span>module
script</span> (on success).</p>

<ol>
<li><p>Let <var>module map</var> be <var>settings</var>'s <span>module map</span>.</p></li>
Expand All @@ -84372,8 +84371,8 @@ interface <dfn>NavigatorOnLine</dfn> {

<li><p>Let <var>request</var> be a new <span data-x="concept-request">request</span> whose
<span data-x="concept-request-url">url</span> is <var>url</var>, <span
data-x="concept-request-destination">destination</span> is "<code data-x="">subresource</code>",
<span data-x="concept-request-type">type</span> is "<code data-x="">script</code>", <span
data-x="concept-request-destination">destination</span> is <var>destination</var>, <span
data-x="concept-request-type">type</span> is "<code data-x="">script</code>", <span
data-x="concept-request-mode">mode</span> is "<code data-x="">cors</code>", <span
data-x="concept-request-credentials-mode">credentials mode</span> is <var>credentials
mode</var>, and <span data-x="concept-request-client">client</span> is
Expand Down Expand Up @@ -93749,9 +93748,8 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> {
<code>SharedWorker</code> object <var>worker</var>, <span>URL</span> <var>url</var>,
<span>URL</span> <var>referrer</var>, <code>MessagePort</code> <var>outside port</var>,
<span>list of relevant <code>Document</code> objects to add</span> <var>docs</var>, possible
<code>WorkerGlobalScope</code> <var>parent worker global scope</var>, a boolean flag <var>is
shared</var>, and a <code>WorkerOptions</code> dictionary <var>options</var>, it must run the
following steps:</p>
<code>WorkerGlobalScope</code> <var>parent worker global scope</var>, and a
<code>WorkerOptions</code> dictionary <var>options</var>, it must run the following steps:</p>

<ol>

Expand All @@ -93765,6 +93763,9 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> {

</li>

<li><p>Let <var>is shared</var> be true if <var>worker</var> is a <code>SharedWorker</code>
object, and false if <var>worker</var> is a <code>Worker</code> object.</p></li>


<li>
<p>Call the JavaScript <span
Expand All @@ -93787,19 +93788,22 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> {
<li><p><span>Set up a worker environment settings object</span> with <var>realm execution
context</var>, and let <var>settings object</var> be the result.</p></li>

<li><p>Let <var>destination</var> be "<code data-x="">worker</code>" if <var>is shared</var> is
false, and "<code data-x="">sharedworker</code>" if it is true.</p></li>

<li>
<p>Obtain <var>script</var> by switching on the value of <var>options</var>'s <code
data-x="">type</code> member:</p>

<dl class="switch">
<dt>"<code data-x="">classic</code>"</dt>
<dd><span>Fetch a classic worker script</span> given <var>url</var>, <var>referrer</var>,
<var>settings object</var>, and <var>is shared</var>.</dd>
<var>settings object</var>, and <var>destination</var>.</dd>

<dt>"<code data-x="">module</code>"</dt>
<dd><span>Fetch a module script tree</span> given <var>url</var>, the value of the <code
data-x="">credentials</code> member of <var>options</var>, and <var>settings
object</var>.</dd>
data-x="">credentials</code> member of <var>options</var>, <var>destination</var>, and
<var>settings object</var>.</dd>
</dl>

<p>If the algorithm asynchronously completes with null, <span>queue a task</span> to <span>fire
Expand Down Expand Up @@ -94273,7 +94277,7 @@ enum <dfn>WorkerType</dfn> { "classic", "module" };

<li><p><span>Run a worker</span> given <var>worker</var>, <var>worker URL</var>, the
<span>incumbent settings object</span>'s <span>creation URL</span>, <var>outside port</var>,
<var>docs</var>, <var>parent worker global scope</var>, false, and <var>options</var>.</p></li>
<var>docs</var>, <var>parent worker global scope</var>, and <var>options</var>.</p></li>

</ol>

Expand Down Expand Up @@ -94432,7 +94436,7 @@ interface <dfn>SharedWorker</dfn> : <span>EventTarget</span> {

<li><p><span>Run a worker</span> given <var>worker</var>, <var>urlRecord</var>, the
<span>incumbent settings object</span>'s <span>creation URL</span>, <var>outside port</var>,
<var>docs</var>, <var>parent worker global scope</var>, true, and <var>options</var>.</p></li>
<var>docs</var>, <var>parent worker global scope</var>, and <var>options</var>.</p></li>

</ol>

Expand Down

0 comments on commit a63c9de

Please sign in to comment.