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

Introduce AbortSignal.timeout() #1032

Merged
merged 1 commit into from
Feb 2, 2022
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
31 changes: 31 additions & 0 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,7 @@ to <a for=AbortSignal>signal abort</a> on <a>this</a>'s <a for=AbortController>s
[Exposed=(Window,Worker)]
interface AbortSignal : EventTarget {
[NewObject] static AbortSignal abort(optional any reason);
[NewObject] static AbortSignal timeout([EnforceRange] unsigned long long milliseconds);

readonly attribute boolean aborted;
readonly attribute any reason;
Expand All @@ -1785,6 +1786,11 @@ interface AbortSignal : EventTarget {
<dd>Returns an {{AbortSignal}} instance whose <a for=AbortSignal>abort reason</a> is set to
<var>reason</var> if not undefined; otherwise to an "{{AbortError!!exception}}" {{DOMException}}.

<dt><code>AbortSignal . <a method for=AbortSignal lt=timeout(milliseconds)>timeout</a>(<var>milliseconds</var>)</code>
<dd>Returns an {{AbortSignal}} instance which will be aborted in <var>milliseconds</var>
milliseconds. Its <a for=AbortSignal>abort reason</a> will be set to a
"{{TimeoutError!!exception}}" {{DOMException}}.

<dt><code><var>signal</var> . <a attribute for=AbortSignal>aborted</a></code>
<dd>Returns true if this {{AbortSignal}}'s {{AbortController}} has signaled to abort; otherwise
false.
Expand Down Expand Up @@ -1834,6 +1840,31 @@ are:
<li>Return <var>signal</var>.
</ol>

<p>The static <dfn method for=AbortSignal><code>timeout(<var>milliseconds</var>)</code></dfn> method
steps are:

<ol>
<li><p>Let <var>signal</var> be a new {{AbortSignal}} object.

<li><p>Let <var>global</var> be <var>signal</var>'s <a>relevant global object</a>.

<li>
<p><a>Run steps after a timeout</a> given <var>global</var>, "<code>AbortSignal-timeout</code>",
<var>milliseconds</var>, and the following step:</p>

<ol>
<li><p><a>Queue a global task</a> on the <a>timer task source</a> given <var>global</var> to
<a for=AbortSignal>signal abort</a> given <var>signal</var> and a new
"{{TimeoutError!!exception}}" {{DOMException}}.
</ol>

<p>For the duration of this timeout, if <var>signal</var> has any event listeners registered for
its {{AbortSignal/abort}} event, there must be a strong reference from <var>global</var> to
<var>signal</var>.

<li><p>Return <var>signal</var>.
</ol>

<p>The <dfn attribute for=AbortSignal>aborted</dfn> getter steps are to return true if <a>this</a>
is [=AbortSignal/aborted=]; otherwise false.

Expand Down