Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: clarify spec around scripts #9872

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 44 additions & 33 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -103849,11 +103849,13 @@ document.querySelector("button").addEventListener("click", bound);

<h5 id="script-structs"><span id="definitions-2"></span>Scripts</h5>

<p>A <dfn data-x="concept-script" export>script</dfn> is one of three possible <span
data-x="struct">structs</span>. All scripts have:</p>
<p>A <dfn data-x="concept-script" export>script</dfn> is one of two possible <span
data-x="struct">structs</span> (namely, a <span>classic script</span> or a
<span>module script</span>). All scripts have:</p>

<dl>
<dt>A <dfn for="script" export>settings object</dfn></dt>
<dt>A <dfn for="script" export data-x="concept-script-settings-object"
Ms2ger marked this conversation as resolved.
Show resolved Hide resolved
id="settings-object">settings object</dfn></dt>

<dd><p>An <span>environment settings object</span>, containing various settings that are shared
with other <span data-x="concept-script">scripts</span> in the same context.</p></dd>
Expand Down Expand Up @@ -103909,8 +103911,8 @@ document.querySelector("button").addEventListener("click", bound);
<dt><dfn for="script" export
data-x="concept-script-script-fetch-options">Fetch options</dfn></dt>

<dd>A <span>script fetch options</span>, containing various options related to fetching this
script or <span data-x="module script">module scripts</span> that it imports.</dd>
<dd>Null or a <span>script fetch options</span>, containing various options related to fetching
this script or <span data-x="module script">module scripts</span> that it imports.</dd>

<dt>A <dfn for="script" export data-x="concept-script-base-url">base
URL</dfn></dt>
Expand Down Expand Up @@ -104922,7 +104924,8 @@ document.querySelector("button").addEventListener("click", bound);
<li><p>Let <var>script</var> be a new <span>classic script</span> that this algorithm will
subsequently initialize.</p></li>

<li><p>Set <var>script</var>'s <span>settings object</span> to <var>settings</var>.</p></li>
<li><p>Set <var>script</var>'s <span data-x="concept-script-settings-object">settings
object</span> to <var>settings</var>.</p></li>

<li><p>Set <var>script</var>'s <span data-x="concept-script-base-url">base URL</span> to
<var>baseURL</var>.</p></li>
Expand Down Expand Up @@ -104974,7 +104977,8 @@ document.querySelector("button").addEventListener("click", bound);
<li><p>Let <var>script</var> be a new <span>module script</span> that this algorithm will
subsequently initialize.</p></li>

<li><p>Set <var>script</var>'s <span>settings object</span> to <var>settings</var>.</p></li>
<li><p>Set <var>script</var>'s <span data-x="concept-script-settings-object">settings
object</span> to <var>settings</var>.</p></li>

<li><p>Set <var>script</var>'s <span data-x="concept-script-base-url">base URL</span> to
<var>baseURL</var>.</p></li>
Expand Down Expand Up @@ -105082,7 +105086,8 @@ document.querySelector("button").addEventListener("click", bound);
<li><p>Let <var>script</var> be a new <span>module script</span> that this algorithm will
subsequently initialize.</p></li>

<li><p>Set <var>script</var>'s <span>settings object</span> to <var>settings</var>.</p></li>
<li><p>Set <var>script</var>'s <span data-x="concept-script-settings-object">settings
object</span> to <var>settings</var>.</p></li>

<li><p>Set <var>script</var>'s <span data-x="concept-script-base-url">base URL</span> and
<span data-x="concept-script-script-fetch-options">fetch options</span> to null.</p></li>
Expand Down Expand Up @@ -105121,7 +105126,8 @@ document.querySelector("button").addEventListener("click", bound);
<li><p>Let <var>script</var> be a new <span>module script</span> that this algorithm will
subsequently initialize.</p></li>

<li><p>Set <var>script</var>'s <span>settings object</span> to <var>settings</var>.</p></li>
<li><p>Set <var>script</var>'s <span data-x="concept-script-settings-object">settings
object</span> to <var>settings</var>.</p></li>

<li><p>Set <var>script</var>'s <span data-x="concept-script-base-url">base URL</span> and
<span data-x="concept-script-script-fetch-options">fetch options</span> to null.</p></li>
Expand Down Expand Up @@ -105193,7 +105199,8 @@ document.querySelector("button").addEventListener("click", bound);
and an optional boolean <var>rethrow errors</var> (default false):</p>

<ol>
<li><p>Let <var>settings</var> be the <span>settings object</span> of <var>script</var>.</p></li>
<li><p>Let <var>settings</var> be the <span data-x="concept-script-settings-object">settings
object</span> of <var>script</var>.</p></li>

<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do
not run" then return <span>NormalCompletion</span>(empty).</p></li>
Expand Down Expand Up @@ -105274,7 +105281,8 @@ document.querySelector("button").addEventListener("click", bound);
and an optional boolean <var>preventErrorReporting</var> (default false):</p>

<ol>
<li><p>Let <var>settings</var> be the <span>settings object</span> of <var>script</var>.</p></li>
<li><p>Let <var>settings</var> be the <span data-x="concept-script-settings-object">settings
object</span> of <var>script</var>.</p></li>

<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do not
run", then return <span>a promise resolved with</span> with undefined.</p></li>
Expand Down Expand Up @@ -105507,9 +105515,9 @@ document.querySelector("button").addEventListener("click", bound);
data-x="concept-script">script</span>, with the problematic position (line number and column
number) in the resource containing the script, using the <span
data-x="concept-settings-object-global">global object</span> specified by the script's
<span>settings object</span> as the target. If the error is still <i
data-x="concept-error-nothandled">not handled</i> after this, then the error may be reported to a
developer console.</p>
<span data-x="concept-script-settings-object">settings object</span> as the target. If the error
is still <i data-x="concept-error-nothandled">not handled</i> after this, then the error may be
reported to a developer console.</p>

<p class="XXX">The existence of both <span data-x="report the error">report an error</span> and
<span data-x="report the exception">report an exception</span> is confusing, and both algorithms
Expand Down Expand Up @@ -105754,8 +105762,8 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
<p>If <var>referringScript</var> is not null, then:</p>

<ol>
<li><p>Set <var>settingsObject</var> to <var>referringScript</var>'s <span>settings
object</span>.</p></li>
<li><p>Set <var>settingsObject</var> to <var>referringScript</var>'s
<span data-x="concept-script-settings-object">settings object</span>.</p></li>

<li><p>Set <var>baseURL</var> to <var>referringScript</var>'s <span
data-x="concept-script-base-url">base URL</span>.</p></li>
Expand Down Expand Up @@ -106527,7 +106535,8 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
<li><p>Let <var>settings object</var> be the <span>current settings object</span>.</p></li>

<li><p>If <var>script</var> is not null, then set <var>settings object</var> to
<var>script</var>'s <span>settings object</span>.</p></li>
<var>script</var>'s <span data-x="concept-script-settings-object">settings
object</span>.</p></li>

<li>
<p>If <var>operation</var> is "<code data-x="">reject</code>", then:</p>
Expand Down Expand Up @@ -106803,8 +106812,9 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
<li>
<p>If <var>active script</var> is not null, set <var>script execution context</var> to a new
<span>JavaScript execution context</span>, with its Function field set to null, its Realm field
set to <var>active script</var>'s <span>settings object</span>'s <span data-x="environment
settings object's realm">realm</span>, and its ScriptOrModule set to <var>active script</var>'s
set to <var>active script</var>'s <span data-x="concept-script-settings-object">settings
object</span>'s <span data-x="environment settings object's realm">realm</span>, and its
ScriptOrModule set to <var>active script</var>'s
<span data-x="concept-script-record">record</span>.</p>

<p class="note">As seen below, this is used in order to propagate the current <span>active
Expand Down Expand Up @@ -107091,8 +107101,8 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
<ol>
<li><p>Set <var>referencingScript</var> to <var>referrer</var>.[[HostDefined]].</p>

<li><p>Set <var>settingsObject</var> to <var>referencingScript</var>'s <span>settings
object</span>.</p></li>
<li><p>Set <var>settingsObject</var> to <var>referencingScript</var>'s <span
data-x="concept-script-settings-object">settings object</span>.</p></li>

<li><p>Set <var>fetchOptions</var> to the new <span>descendant script fetch options</span> for
<var>referencingScript</var>'s <span data-x="concept-script-script-fetch-options">fetch
Expand Down Expand Up @@ -107152,14 +107162,14 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
<ol>
<li><p>Set <var>destination</var> to <var>loadState</var>.[[Destination]].</p></li>

<li><p>Set <var>fetchClient</var> <var>loadState</var>.[[FetchClient]].</p></li>
<li><p>Set <var>fetchClient</var> to <var>loadState</var>.[[FetchClient]].</p></li>
</ol>
</li>

<li>
<p><span>Fetch a single imported module script</span> given <var>url</var>,
<var>fetchClient</var>, <var>destination</var>, <var>fetchOptions</var>,
<var>settingsObject</var> <var>fetchReferrer</var>, <var>moduleRequest</var>, and
<var>settingsObject</var>, <var>fetchReferrer</var>, <var>moduleRequest</var>, and
<var>onSingleFetchComplete</var> as defined below. If <var>loadState</var> is not undefined and
<var>loadState</var>.[[PerformFetch]] is not null, pass <var>loadState</var>.[[PerformFetch]]
along as well.</p>
Expand Down Expand Up @@ -107191,8 +107201,8 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
</li>

<li><p>Otherwise, set <var>completion</var> to <span>Completion Record</span> { [[Type]]:
normal, [[Value]]: <var>result</var>'s <span data-x="concept-script-record">record</span>,
[[Target]]: empty }.</p></li>
normal, [[Value]]: <var>moduleScript</var>'s
<span data-x="concept-script-record">record</span>, [[Target]]: empty }.</p></li>

<li><p>Perform <span>FinishLoadingImportedModule</span>(<var>referrer</var>,
<var>moduleRequest</var>, <var>payload</var>, <var>completion</var>).</p></li>
Expand Down Expand Up @@ -107468,7 +107478,7 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
the browsing context's <span>active document</span>.</p></li>

<li><p>If the task is being queued by or for a <span data-x="concept-script">script</span>, then
return the script's <span>settings object</span>'s <span
return the script's <span data-x="concept-script-settings-object">settings object</span>'s <span
data-x="concept-settings-object-global">global object</span>'s <span
data-x="concept-document-window">associated <code>Document</code></span>.</p></li>

Expand Down Expand Up @@ -116550,9 +116560,9 @@ interface <dfn interface>SharedWorker</dfn> : <span>EventTarget</span> {
<li>
<p>If <var>worker global scope</var> is not null, but the user agent has been
configured to disallow communication between the worker represented by the <var>worker global
scope</var> and the <span data-x="concept-script">scripts</span> whose <span data-x="settings
object">settings object</span> is <var>outside settings</var>, then set <var>worker global
scope</var> to null.</p>
scope</var> and the <span data-x="concept-script">scripts</span> whose <span
data-x="concept-script-settings-object">settings object</span> is <var>outside settings</var>,
then set <var>worker global scope</var> to null.</p>

<p class="note">For example, a user agent could have a development mode that isolates a
particular <span>top-level traversable</span> from all other pages, and scripts in that
Expand Down Expand Up @@ -132753,10 +132763,11 @@ if (s = prompt('What is your name?')) {
<li>None of the elements in the <code>Document</code> are in any of the following namespaces: <span>HTML namespace</span>, <span>SVG namespace</span>, <span>MathML namespace</span>
<li>The <code>Document</code> has no <span>focusable area</span> (e.g. from XLink) other than the <span>viewport</span>.
<li>The <code>Document</code> has no <span data-x="hyperlink">hyperlinks</span> (e.g. from XLink).
<li>There exists no <span data-x="concept-script">script</span> whose <span>settings
object</span>'s <span data-x="concept-settings-object-global">global object</span> is a
<code>Window</code> object with this <code>Document</code> as its <span
data-x="concept-document-window">associated <code>Document</code></span>.
<li>There exists no <span data-x="concept-script">script</span> whose <span
data-x="concept-script-settings-object">settings object</span>'s <span
data-x="concept-settings-object-global">global object</span> is a <code>Window</code> object with
this <code>Document</code> as its <span data-x="concept-document-window">associated
<code>Document</code></span>.
<li>None of the elements in the <code>Document</code> have any registered event listeners.
</ul>

Expand Down