Skip to content

Commit 86beb6d

Browse files
committed
wip: factor into a "fire an error event" alg
1 parent 8f8e65c commit 86beb6d

File tree

1 file changed

+74
-28
lines changed

1 file changed

+74
-28
lines changed

source

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -107754,6 +107754,71 @@ document.querySelector("button").addEventListener("click", bound);
107754107754

107755107755
<div w-nodev>
107756107756

107757+
<p>When the user agent is to <dfn>fire an error event</dfn> named <var>e</var> at
107758+
<code>EventTarget</code> <var>target</var> with a JavaScript value <var>error</var>, an optional
107759+
description of how IDL attributes are to be initialized, and an optional boolean <dfn
107760+
data-x="fire-error-event-redactError"><var>redactError</var></dfn> (default false), it must run
107761+
these steps:</p>
107762+
107763+
<ol>
107764+
<li><p>Let <var>event</var> be the result of <span>creating an event</span> using
107765+
<code>ErrorEvent</code>.</p></li>
107766+
107767+
<li><p>Initialize <var>event</var>'s <code data-x="dom-Event-type">type</code> attribute to
107768+
<var>e</var>.</p></li>
107769+
107770+
<li>
107771+
<p>If <var>redactError</var> is true:</p>
107772+
107773+
<ol>
107774+
<li><p>Initialize <var>event</var>'s <code data-x="dom-ErrorEvent-error">error</code>
107775+
attribute to null.</p></li>
107776+
107777+
<li><p>Initialize <var>event</var>'s <code data-x="dom-ErrorEvent-message">message</code>
107778+
attribute to "<code data-x="">Script error.</code>".</p></li>
107779+
107780+
<li><p>Initialize <var>event</var>'s <code data-x="dom-ErrorEvent-filename">filename</code>
107781+
attribute to the empty string.</p></li>
107782+
107783+
<li><p>Initialize <var>event</var>'s <code data-x="dom-ErrorEvent-lineno">lineno</code>
107784+
attribute to 0.</p></li>
107785+
107786+
<li><p>Initialize <var>event</var>'s <code data-x="dom-ErrorEvent-colno">colno</code>
107787+
attribute to 0.</p></li>
107788+
</ol>
107789+
</li>
107790+
107791+
<li>
107792+
<p>Otherwise:</p>
107793+
107794+
<ol>
107795+
<li><p>Initialize <var>event</var>'s <code data-x="dom-ErrorEvent-error">error</code>
107796+
attribute to <var>error</var>.</p></li>
107797+
107798+
<li>
107799+
<p>
107800+
<!-- INSERT TRACKING-->
107801+
Initialize <var>event</var>'s <code data-x="dom-ErrorEvent-message">message</code>,
107802+
<code data-x="dom-ErrorEvent-filename">filename</code>, <code
107803+
data-x="dom-ErrorEvent-lineno">lineno</code>, and <code
107804+
data-x="dom-ErrorEvent-colno">colno</code> to <span>implementation-defined</span> values
107805+
derived from <var>error</var>.
107806+
</p>
107807+
107808+
<p class="note">Browsers implement behavior not specified here or in <ref>JAVASCRIPT</ref> to
107809+
gather values which are helpful, including in unusual cases (e.g., <code
107810+
data-x="">eval</code>). In the future, this might be specified in greater detail.</p>
107811+
</li>
107812+
</ol>
107813+
</li>
107814+
107815+
<li><p>Initialize any other IDL attributes of <var>event</var> as described in the invocation of
107816+
this algorithm.</p></li>
107817+
107818+
<li><p>Return the result of <span data-x="concept-event-dispatch">dispatching</span>
107819+
<var>event</var> at <var>target</var>.</p></li>
107820+
</ol>
107821+
107757107822
<p>When the user agent is required to <span id="report-the-error"></span><span
107758107823
id="report-the-exception"></span><dfn export>report an exception</dfn> <var>exception</var> which
107759107824
is a JavaScript value, for a particular <span>global object</span> <var>global</var>, optional
@@ -107764,43 +107829,22 @@ document.querySelector("button").addEventListener("click", bound);
107764107829
<ol>
107765107830
<li>Let <var>notHandled</var> be true.</li>
107766107831

107767-
<li>
107768-
<p>
107769-
<!-- INSERT TRACKING-->
107770-
Let <var>message</var>, <var>filename</var>, <var>line</var> and <var>col</var> be
107771-
<span>implementation-defined</span> values derived from <var>exception</var>.
107772-
</p>
107773-
107774-
<p class="note">Browsers implement behavior not specified here or in <ref>JAVASCRIPT</ref> to
107775-
gather values which are helpful, including in unusual cases (e.g., <code
107776-
data-x="">eval</code>). In the future, this might be specified in greater detail.</p>
107777-
</li>
107778-
107779107832
<li><p>If <var>script</var> is a <span>classic script</span> and <var>script</var>'s <span>muted
107780-
errors</span> is true, then set <var>message</var> to "<code data-x="">Script error.</code>",
107781-
<var>filename</var> to the empty string, <var>line</var> and <var>col</var> to 0, and
107782-
<var>redactError</var> to true.</p></li>
107833+
errors</span> is true, then set <var>redactError</var> to true.</p></li>
107783107834

107784107835
<li>
107785107836
<p>If <var>global</var> is not <span>in error reporting mode</span>, then:</p>
107786107837

107787107838
<ol>
107788107839
<li>Set <var>global</var>'s <span>in error reporting mode</span> to true.</li>
107789107840

107790-
<li><p>Let <var>error</var> be null if <var>redactError</var> is true or <var>exception</var>
107791-
is not a JavaScript value, and <var>exception</var> otherwise.</p></li>
107792-
107793107841
<li>
107794-
<p>If <var>global</var> implements <code>EventTarget</code>, then set <var>notHandled</var> to
107795-
the result of <span data-x="concept-event-fire">firing an event</span> named <code
107796-
data-x="event-error">error</code> at <var>global</var>, using <code>ErrorEvent</code>, with
107797-
the <code data-x="dom-Event-cancelable">cancelable</code> attribute initialized to true, the
107798-
<code data-x="dom-ErrorEvent-message">message</code> attribute initialized to
107799-
<var>message</var>, the <code data-x="dom-ErrorEvent-filename">filename</code> attribute
107800-
initialized to <var>filename</var>, the <code data-x="dom-ErrorEvent-lineno">lineno</code>
107801-
attribute initialized to <var>line</var>, the <code data-x="dom-ErrorEvent-colno">colno</code>
107802-
attribute initialized to <var>col</var>, and the <code
107803-
data-x="dom-ErrorEvent-error">error</code> attribute initialized to <var>error</var>.</p>
107842+
<p>If <var>global</var> implements <code>EventTarget</code>, then set <var>notHandled</var>
107843+
to the result of <span>firing an error event</span> named <code
107844+
data-x="event-error">error</code> at <var>global</var> with <var>exception</var>, with the
107845+
<code data-x="dom-Event-cancelable">cancelable</code> attribute initialized to true, and with
107846+
<span data-x="fire-error-event-redactError">redactError</span> set to
107847+
<var>redactError</var>.</p>
107804107848

107805107849
<p class="note">Returning true in an event handler cancels the event per <span>the event
107806107850
handler processing algorithm</span>.</p>
@@ -107824,6 +107868,8 @@ document.querySelector("button").addEventListener("click", bound);
107824107868
<li><p>Let <var>workerObject</var> be the <code>Worker</code> object associated with
107825107869
<var>global</var>.</p></li>
107826107870

107871+
<!-- plumbing the values into here is messy, though, because we can't actually expose the
107872+
error in another realm even though the filename etc still can be -->
107827107873
<li><p>Set <var>notHandled</var> be the result of <span data-x="concept-event-fire">firing
107828107874
an event</span> named <code data-x="event-error">error</code> at <var>workerObject</var>,
107829107875
using <code>ErrorEvent</code>, with the <code

0 commit comments

Comments
 (0)