Skip to content

Commit a9a2724

Browse files
committed
Change how module scripts are fetched
* Module scripts are always fetched with credentials mode "same-origin" by default and can no longer use "omit". This makes them match other high-level platform features. * The top-level script for module workers is always fetched with request mode "same-origin" and credentials mode "same-origin". Cross-origin workers did not quite work due to service workers. * Any module worker import scripts are fetched with request credentials mode "same-origin" and this cannot be configured for now. Fixes #2557 and fixes #3109.
1 parent ee5ff06 commit a9a2724

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

source

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7012,8 +7012,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
70127012

70137013
<dl class="switch">
70147014
<dt><span data-x="attr-crossorigin-none">No CORS</span></dt>
7015-
<dd>"<code data-x="">omit</code>"</dd>
7016-
70177015
<dt><span data-x="attr-crossorigin-anonymous">Anonymous</span></dt>
70187016
<dd>"<code data-x="">same-origin</code>"</dd>
70197017

@@ -86571,8 +86569,9 @@ interface <dfn>ApplicationCache</dfn> : <span>EventTarget</span> {
8657186569
empty string, <span data-x="concept-script-fetch-options-parser">parser metadata</span> is "<code
8657286570
data-x="">not-parser-inserted</code>", <span
8657386571
data-x="concept-script-fetch-options-credentials">credentials mode</span> is "<code
86574-
data-x="">omit</code>", and <span data-x="concept-script-fetch-options-referrer-policy">referrer
86575-
policy</span> is the empty string.</p>
86572+
data-x="">same-origin</code>", and <span
86573+
data-x="concept-script-fetch-options-referrer-policy">referrer policy</span> is the empty
86574+
string.</p>
8657686575

8657786576
<p>Given a <span data-x="concept-request">request</span> <var>request</var> and a <span>script
8657886577
fetch options</span> <var>options</var>, we define:</p>
@@ -86832,9 +86831,9 @@ interface <dfn>ApplicationCache</dfn> : <span>EventTarget</span> {
8683286831

8683386832
<p>To <dfn data-export="" id="fetch-a-module-worker-script-tree">fetch a module worker script
8683486833
graph</dfn> given a <var>url</var>, a <var>fetch client settings object</var>, a
86835-
<var>destination</var>, a <var>credentials mode</var>, and a <var>module map settings
86836-
object</var>, run these steps. The algorithm will asynchronously complete with either null (on
86837-
failure) or a <span>module script</span> (on success).</p>
86834+
<var>destination</var>, and a <var>module map settings object</var>, run these steps. The
86835+
algorithm will asynchronously complete with either null (on failure) or a <span>module
86836+
script</span> (on success).</p>
8683886837

8683986838
<ol>
8684086839
<li><p>Let <var>visited set</var> be « <var>url</var> ».</p></li>
@@ -86844,9 +86843,10 @@ interface <dfn>ApplicationCache</dfn> : <span>EventTarget</span> {
8684486843
data-x="concept-script-fetch-options-integrity">integrity metadata</span> is the empty string,
8684586844
<span data-x="concept-script-fetch-options-parser">parser metadata</span> is "<code
8684686845
data-x="">not-parser-inserted</code>", <span
86847-
data-x="concept-script-fetch-options-credentials">credentials mode</span> is <var>credentials
86848-
mode</var>, and <span data-x="concept-script-fetch-options-referrer-policy">referrer
86849-
policy</span> is the empty string.</p>
86846+
data-x="concept-script-fetch-options-credentials">credentials mode</span> is "<code
86847+
data-x="">same-origin</code>", and <span
86848+
data-x="concept-script-fetch-options-referrer-policy">referrer policy</span> is the empty
86849+
string.</p>
8685086850

8685186851
<li><p>Perform the <span>internal module script graph fetching procedure</span> given
8685286852
<var>url</var>, <var>fetch client settings object</var>, <var>destination</var>,
@@ -86930,6 +86930,11 @@ interface <dfn>ApplicationCache</dfn> : <span>EventTarget</span> {
8693086930
data-x="concept-request-client">client</span> is <var>fetch client settings
8693186931
object</var>.</p></li>
8693286932

86933+
<li><p>If <var>destination</var> is "<code data-x="">worker</code>" or "<code
86934+
data-x="">sharedworker</code>" and the <var>top-level module fetch</var> flag is set, then set
86935+
<var>request</var>'s <span data-x="concept-request-mode">mode</span> to "<code
86936+
data-x="">same-origin</code>".
86937+
8693386938
<li><p><span>Set up the module script request</span> given <var>request</var> and
8693486939
<var>options</var>.</p></li>
8693586940

@@ -97255,8 +97260,7 @@ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
9725597260

9725697261
<dt>"<code data-x="">module</code>"</dt>
9725797262
<dd><span>Fetch a module worker script graph</span> given <var>url</var>, <var>outside
97258-
settings</var>, <var>destination</var>, the value of the <code data-x="">credentials</code>
97259-
member of <var>options</var>, and <var>inside settings</var>.</dd>
97263+
settings</var>, <var>destination</var>, and <var>inside settings</var>.</dd>
9726097264
</dl>
9726197265

9726297266
<p>In both cases, to <span data-x="fetching-scripts-perform-fetch">perform the fetch</span>
@@ -97669,7 +97673,6 @@ interface <dfn>Worker</dfn> : <span>EventTarget</span> {
9766997673

9767097674
dictionary <dfn>WorkerOptions</dfn> {
9767197675
<span>WorkerType</span> type = "classic";
97672-
<span>RequestCredentials</span> credentials = "omit"; // credentials is only used if type is "module"
9767397676
DOMString name = "";
9767497677
};
9767597678

@@ -97684,9 +97687,8 @@ enum <dfn>WorkerType</dfn> { "classic", "module" };
9768497687
communication channel. <var>options</var> can be used to define the <span
9768597688
data-x="concept-WorkerGlobalScope-name">name</span> of that global environment via the <code
9768697689
data-x="">name</code> option, primarily for debugging purposes. It can also ensure this new
97687-
global environment supports JavaScript modules (specify <code data-x="">type: "module"</code>),
97688-
and if that is specified, can also be used to specify how <var>scriptURL</var> is fetched through
97689-
the <code data-x="">credentials</code> option.
97690+
global environment supports JavaScript modules (specify <code
97691+
data-x="">type: "module"</code>).</dd>
9769097692

9769197693
<dt><var>worker</var> . <code subdfn data-x="dom-Worker-terminate">terminate</code>()</dt>
9769297694
<dd>Aborts <var>worker</var>'s associated global environment.</dd>
@@ -97814,9 +97816,7 @@ interface <dfn>SharedWorker</dfn> : <span>EventTarget</span> {
9781497816
represents the communication channel. <var>options</var> can be used to define the <span
9781597817
data-x="concept-WorkerGlobalScope-name">name</span> of that global environment via the <code
9781697818
data-x="">name</code> option. It can also ensure this new global environment supports JavaScript
97817-
modules (specify <code data-x="">type: "module"</code>), and if that is specified, can also be
97818-
used to specify how <var>scriptURL</var> is fetched through the <code
97819-
data-x="">credentials</code> option.</dd>
97819+
modules (specify <code data-x="">type: "module"</code>).</dd>
9782097820

9782197821
<dt><var>sharedWorker</var> . <code subdfn data-x="dom-SharedWorker-port">port</code></dt>
9782297822
<dd>Returns <var>sharedWorker</var>'s <code>MessagePort</code> object which can be used to

0 commit comments

Comments
 (0)