<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[285428] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/285428">285428</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-11-08 13:36:35 -0800 (Mon, 08 Nov 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add abort reason to AbortSignal
https://bugs.webkit.org/show_bug.cgi?id=232299
<rdar://problem/84921281>

Reviewed by Alexey Shvayka.

LayoutTests/imported/w3c:

Import https://github.com/web-platform-tests/wpt/commit/9c7dfd2809b6c3a209a2c4df43c1d6816e6bfc1b from
upstream WPT to gain layout test coverage and rebaseline the test.

* web-platform-tests/dom/abort/event.any-expected.txt:
* web-platform-tests/dom/abort/event.any.js:
* web-platform-tests/dom/abort/event.any.worker-expected.txt:

Source/WebCore:

Add abort reason to AbortSignal:
- https://github.com/whatwg/dom/pull/1027
- https://dom.spec.whatwg.org/#abortsignal

No new tests, updated & rebaselined existing WPT test.

* bindings/js/JSAbortSignalCustom.cpp:
(WebCore::JSAbortSignal::visitAdditionalChildren):
* dom/AbortController.cpp:
(WebCore::AbortController::abort):
* dom/AbortController.h:
* dom/AbortController.idl:
* dom/AbortSignal.cpp:
(WebCore::AbortSignal::abort):
(WebCore::AbortSignal::AbortSignal):
(WebCore::AbortSignal::signalAbort):
(WebCore::AbortSignal::signalFollow):
* dom/AbortSignal.h:
* dom/AbortSignal.idl:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomaborteventanyexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomaborteventanyjs">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomaborteventanyworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.worker-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSAbortSignalCustomcpp">trunk/Source/WebCore/bindings/js/JSAbortSignalCustom.cpp</a></li>
<li><a href="#trunkSourceWebCoredomAbortControllercpp">trunk/Source/WebCore/dom/AbortController.cpp</a></li>
<li><a href="#trunkSourceWebCoredomAbortControllerh">trunk/Source/WebCore/dom/AbortController.h</a></li>
<li><a href="#trunkSourceWebCoredomAbortControlleridl">trunk/Source/WebCore/dom/AbortController.idl</a></li>
<li><a href="#trunkSourceWebCoredomAbortSignalcpp">trunk/Source/WebCore/dom/AbortSignal.cpp</a></li>
<li><a href="#trunkSourceWebCoredomAbortSignalh">trunk/Source/WebCore/dom/AbortSignal.h</a></li>
<li><a href="#trunkSourceWebCoredomAbortSignalidl">trunk/Source/WebCore/dom/AbortSignal.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2021-11-08  Chris Dumez  <cdumez@apple.com>
+
+        Add abort reason to AbortSignal
+        https://bugs.webkit.org/show_bug.cgi?id=232299
+        <rdar://problem/84921281>
+
+        Reviewed by Alexey Shvayka.
+
+        Import https://github.com/web-platform-tests/wpt/commit/9c7dfd2809b6c3a209a2c4df43c1d6816e6bfc1b from
+        upstream WPT to gain layout test coverage and rebaseline the test.
+
+        * web-platform-tests/dom/abort/event.any-expected.txt:
+        * web-platform-tests/dom/abort/event.any.js:
+        * web-platform-tests/dom/abort/event.any.worker-expected.txt:
+
</ins><span class="cx"> 2021-11-08  Tim Nguyen  <ntim@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Stop skipping html/semantics/interactive-elements/the-details-element/toggleEvent.html in import-expectations.json
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomaborteventanyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any-expected.txt (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any-expected.txt       2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any-expected.txt  2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -4,4 +4,9 @@
</span><span class="cx"> PASS controller.abort() should do nothing the second time it is called
</span><span class="cx"> PASS event handler should not be called if added after controller.abort()
</span><span class="cx"> PASS the abort event should have the right properties
</span><ins>+PASS AbortController abort(reason) should set signal.reason
+PASS aborting AbortController without reason creates an "AbortError" DOMException
+PASS AbortController abort(undefined) creates an "AbortError" DOMException
+PASS static aborting signal should have right properties
+PASS static aborting signal with reason should set signal.reason
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomaborteventanyjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.js (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.js 2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.js    2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -4,6 +4,8 @@
</span><span class="cx">   let state = "begin";
</span><span class="cx"> 
</span><span class="cx">   assert_false(s.aborted);
</span><ins>+  assert_true("reason" in s, "signal has reason property");
+  assert_equals(s.reason, undefined, "signal.reason is initially undefined");
</ins><span class="cx"> 
</span><span class="cx">   s.addEventListener("abort",
</span><span class="cx">     t.step_func(e => {
</span><span class="lines">@@ -15,6 +17,8 @@
</span><span class="cx"> 
</span><span class="cx">   assert_equals(state, "aborted");
</span><span class="cx">   assert_true(s.aborted);
</span><ins>+  assert_true(s.reason instanceof DOMException, "signal.reason is DOMException");
+  assert_equals(s.reason.name, "AbortError", "signal.reason is AbortError");
</ins><span class="cx"> 
</span><span class="cx">   c.abort();
</span><span class="cx"> }, "AbortController abort() should fire event synchronously");
</span><span class="lines">@@ -64,4 +68,62 @@
</span><span class="cx">   controller.abort();
</span><span class="cx"> }, "the abort event should have the right properties");
</span><span class="cx"> 
</span><ins>+test(t => {
+  const controller = new AbortController();
+  const signal = controller.signal;
+
+  assert_true("reason" in signal, "signal has reason property");
+  assert_equals(signal.reason, undefined, "signal.reason is initially undefined");
+
+  const reason = Error("hello");
+  controller.abort(reason);
+
+  assert_true(signal.aborted, "signal.aborted");
+  assert_equals(signal.reason, reason, "signal.reason");
+}, "AbortController abort(reason) should set signal.reason");
+
+test(t => {
+  const controller = new AbortController();
+  const signal = controller.signal;
+
+  assert_true("reason" in signal, "signal has reason property");
+  assert_equals(signal.reason, undefined, "signal.reason is initially undefined");
+
+  controller.abort();
+
+  assert_true(signal.aborted, "signal.aborted");
+  assert_true(signal.reason instanceof DOMException, "signal.reason is DOMException");
+  assert_equals(signal.reason.name, "AbortError", "signal.reason is AbortError");
+}, "aborting AbortController without reason creates an \"AbortError\" DOMException");
+
+test(t => {
+  const controller = new AbortController();
+  const signal = controller.signal;
+
+  assert_true("reason" in signal, "signal has reason property");
+  assert_equals(signal.reason, undefined, "signal.reason is initially undefined");
+
+  controller.abort(undefined);
+
+  assert_true(signal.aborted, "signal.aborted");
+  assert_true(signal.reason instanceof DOMException, "signal.reason is DOMException");
+  assert_equals(signal.reason.name, "AbortError", "signal.reason is AbortError");
+}, "AbortController abort(undefined) creates an \"AbortError\" DOMException");
+
+test(t => {
+  const signal = AbortSignal.abort();
+
+  assert_true(signal.aborted, "signal.aborted");
+  assert_true(signal.reason instanceof DOMException, "signal.reason is DOMException");
+  assert_equals(signal.reason.name, "AbortError", "signal.reason is AbortError");
+}, "static aborting signal should have right properties");
+
+test(t => {
+  const reason = Error("hello");
+  const signal = AbortSignal.abort(reason);
+
+  assert_true(signal.aborted, "signal.aborted");
+  assert_equals(signal.reason, reason, "signal.reason");
+}, "static aborting signal with reason should set signal.reason");
+
</ins><span class="cx"> done();
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomaborteventanyworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.worker-expected.txt (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.worker-expected.txt        2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.worker-expected.txt   2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -4,4 +4,9 @@
</span><span class="cx"> PASS controller.abort() should do nothing the second time it is called
</span><span class="cx"> PASS event handler should not be called if added after controller.abort()
</span><span class="cx"> PASS the abort event should have the right properties
</span><ins>+PASS AbortController abort(reason) should set signal.reason
+PASS aborting AbortController without reason creates an "AbortError" DOMException
+PASS AbortController abort(undefined) creates an "AbortError" DOMException
+PASS static aborting signal should have right properties
+PASS static aborting signal with reason should set signal.reason
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/Source/WebCore/ChangeLog      2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2021-11-08  Chris Dumez  <cdumez@apple.com>
+
+        Add abort reason to AbortSignal
+        https://bugs.webkit.org/show_bug.cgi?id=232299
+        <rdar://problem/84921281>
+
+        Reviewed by Alexey Shvayka.
+
+        Add abort reason to AbortSignal:
+        - https://github.com/whatwg/dom/pull/1027
+        - https://dom.spec.whatwg.org/#abortsignal
+
+        No new tests, updated & rebaselined existing WPT test.
+
+        * bindings/js/JSAbortSignalCustom.cpp:
+        (WebCore::JSAbortSignal::visitAdditionalChildren):
+        * dom/AbortController.cpp:
+        (WebCore::AbortController::abort):
+        * dom/AbortController.h:
+        * dom/AbortController.idl:
+        * dom/AbortSignal.cpp:
+        (WebCore::AbortSignal::abort):
+        (WebCore::AbortSignal::AbortSignal):
+        (WebCore::AbortSignal::signalAbort):
+        (WebCore::AbortSignal::signalFollow):
+        * dom/AbortSignal.h:
+        * dom/AbortSignal.idl:
+
</ins><span class="cx"> 2021-11-08  Ross Kirsling  <ross.kirsling@sony.com>
</span><span class="cx"> 
</span><span class="cx">         Fix !ENABLE(ACCESSIBILITY) build following r285399
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSAbortSignalCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSAbortSignalCustom.cpp (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSAbortSignalCustom.cpp 2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/Source/WebCore/bindings/js/JSAbortSignalCustom.cpp    2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -46,4 +46,12 @@
</span><span class="cx">     return visitor.containsOpaqueRoot(&abortSignal);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template<typename Visitor>
+void JSAbortSignal::visitAdditionalChildren(Visitor& visitor)
+{
+    wrapped().reason().visit(visitor);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSAbortSignal);
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomAbortControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AbortController.cpp (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AbortController.cpp     2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/Source/WebCore/dom/AbortController.cpp        2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -27,6 +27,8 @@
</span><span class="cx"> #include "AbortController.h"
</span><span class="cx"> 
</span><span class="cx"> #include "AbortSignal.h"
</span><ins>+#include "DOMException.h"
+#include "JSDOMException.h"
</ins><span class="cx"> #include <wtf/IsoMallocInlines.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -50,9 +52,13 @@
</span><span class="cx">     return m_signal.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void AbortController::abort()
</del><ins>+void AbortController::abort(JSDOMGlobalObject& globalObject, JSC::JSValue reason)
</ins><span class="cx"> {
</span><del>-    m_signal->signalAbort();
</del><ins>+    ASSERT(reason);
+    if (reason.isUndefined())
+        reason = toJS(&globalObject, &globalObject, DOMException::create(AbortError));
+
+    m_signal->signalAbort(reason);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomAbortControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AbortController.h (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AbortController.h       2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/Source/WebCore/dom/AbortController.h  2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -29,9 +29,14 @@
</span><span class="cx"> #include <wtf/Ref.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> 
</span><ins>+namespace JSC {
+class JSValue;
+}
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class AbortSignal;
</span><ins>+class JSDOMGlobalObject;
</ins><span class="cx"> class ScriptExecutionContext;
</span><span class="cx"> 
</span><span class="cx"> class AbortController final : public ScriptWrappable, public RefCounted<AbortController> {
</span><span class="lines">@@ -41,7 +46,7 @@
</span><span class="cx">     ~AbortController();
</span><span class="cx"> 
</span><span class="cx">     AbortSignal& signal();
</span><del>-    void abort();
</del><ins>+    void abort(JSDOMGlobalObject&, JSC::JSValue reason);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     explicit AbortController(ScriptExecutionContext&);
</span></span></pre></div>
<a id="trunkSourceWebCoredomAbortControlleridl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AbortController.idl (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AbortController.idl     2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/Source/WebCore/dom/AbortController.idl        2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -32,5 +32,5 @@
</span><span class="cx"> 
</span><span class="cx">     [SameObject] readonly attribute AbortSignal signal;
</span><span class="cx"> 
</span><del>-    undefined abort();
</del><ins>+    [CallWith=GlobalObject] undefined abort(optional any reason);
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoredomAbortSignalcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AbortSignal.cpp (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AbortSignal.cpp 2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/Source/WebCore/dom/AbortSignal.cpp    2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -27,8 +27,10 @@
</span><span class="cx"> #include "AbortSignal.h"
</span><span class="cx"> 
</span><span class="cx"> #include "AbortAlgorithm.h"
</span><ins>+#include "DOMException.h"
</ins><span class="cx"> #include "Event.h"
</span><span class="cx"> #include "EventNames.h"
</span><ins>+#include "JSDOMException.h"
</ins><span class="cx"> #include "ScriptExecutionContext.h"
</span><span class="cx"> #include <wtf/IsoMallocInlines.h>
</span><span class="cx"> 
</span><span class="lines">@@ -42,19 +44,23 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // https://dom.spec.whatwg.org/#dom-abortsignal-abort
</span><del>-Ref<AbortSignal> AbortSignal::abort(ScriptExecutionContext& context)
</del><ins>+Ref<AbortSignal> AbortSignal::abort(JSDOMGlobalObject& globalObject, ScriptExecutionContext& context, JSC::JSValue reason)
</ins><span class="cx"> {
</span><del>-    return adoptRef(*new AbortSignal(context, Aborted::Yes));
</del><ins>+    ASSERT(reason);
+    if (reason.isUndefined())
+        reason = toJS(&globalObject, &globalObject, DOMException::create(AbortError));
+    return adoptRef(*new AbortSignal(context, Aborted::Yes, reason));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-AbortSignal::AbortSignal(ScriptExecutionContext& context, Aborted aborted)
</del><ins>+AbortSignal::AbortSignal(ScriptExecutionContext& context, Aborted aborted, JSC::JSValue reason)
</ins><span class="cx">     : ContextDestructionObserver(&context)
</span><span class="cx">     , m_aborted(aborted == Aborted::Yes)
</span><ins>+    , m_reason(reason)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // https://dom.spec.whatwg.org/#abortsignal-signal-abort
</span><del>-void AbortSignal::signalAbort()
</del><ins>+void AbortSignal::signalAbort(JSC::JSValue reason)
</ins><span class="cx"> {
</span><span class="cx">     // 1. If signal's aborted flag is set, then return.
</span><span class="cx">     if (m_aborted)
</span><span class="lines">@@ -63,6 +69,9 @@
</span><span class="cx">     // 2. Set signal’s aborted flag.
</span><span class="cx">     m_aborted = true;
</span><span class="cx"> 
</span><ins>+    ASSERT(reason);
+    m_reason = reason;
+
</ins><span class="cx">     Ref protectedThis { *this };
</span><span class="cx">     auto algorithms = std::exchange(m_algorithms, { });
</span><span class="cx">     for (auto& algorithm : algorithms)
</span><span class="lines">@@ -79,7 +88,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (signal.aborted()) {
</span><del>-        signalAbort();
</del><ins>+        signalAbort(signal.reason());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -87,7 +96,7 @@
</span><span class="cx">     m_followingSignal = signal;
</span><span class="cx">     signal.addAlgorithm([weakThis = WeakPtr { this }] {
</span><span class="cx">         if (weakThis)
</span><del>-            weakThis->signalAbort();
</del><ins>+            weakThis->signalAbort(weakThis->m_followingSignal ? static_cast<JSC::JSValue>(weakThis->m_followingSignal->reason()) : JSC::jsUndefined());
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomAbortSignalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AbortSignal.h (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AbortSignal.h   2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/Source/WebCore/dom/AbortSignal.h      2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "ContextDestructionObserver.h"
</span><span class="cx"> #include "EventTarget.h"
</span><span class="cx"> #include "JSDOMPromiseDeferred.h"
</span><ins>+#include "JSValueInWrappedObject.h"
</ins><span class="cx"> #include <wtf/Function.h>
</span><span class="cx"> #include <wtf/Ref.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="lines">@@ -43,14 +44,15 @@
</span><span class="cx"> public:
</span><span class="cx">     static Ref<AbortSignal> create(ScriptExecutionContext&);
</span><span class="cx"> 
</span><del>-    static Ref<AbortSignal> abort(ScriptExecutionContext&);
</del><ins>+    static Ref<AbortSignal> abort(JSDOMGlobalObject&, ScriptExecutionContext&, JSC::JSValue reason);
</ins><span class="cx"> 
</span><span class="cx">     static bool whenSignalAborted(AbortSignal&, Ref<AbortAlgorithm>&&);
</span><span class="cx"> 
</span><del>-    void signalAbort();
</del><ins>+    void signalAbort(JSC::JSValue reason);
</ins><span class="cx">     void signalFollow(AbortSignal&);
</span><span class="cx"> 
</span><span class="cx">     bool aborted() const { return m_aborted; }
</span><ins>+    const JSValueInWrappedObject& reason() const { return m_reason; }
</ins><span class="cx"> 
</span><span class="cx">     using RefCounted::ref;
</span><span class="cx">     using RefCounted::deref;
</span><span class="lines">@@ -62,7 +64,7 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     enum class Aborted : bool { No, Yes };
</span><del>-    explicit AbortSignal(ScriptExecutionContext&, Aborted = Aborted::No);
</del><ins>+    explicit AbortSignal(ScriptExecutionContext&, Aborted = Aborted::No, JSC::JSValue reason = { });
</ins><span class="cx"> 
</span><span class="cx">     // EventTarget.
</span><span class="cx">     EventTargetInterface eventTargetInterface() const final { return AbortSignalEventTargetInterfaceType; }
</span><span class="lines">@@ -73,6 +75,7 @@
</span><span class="cx">     bool m_aborted { false };
</span><span class="cx">     Vector<Algorithm> m_algorithms;
</span><span class="cx">     WeakPtr<AbortSignal> m_followingSignal;
</span><ins>+    JSValueInWrappedObject m_reason;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomAbortSignalidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AbortSignal.idl (285427 => 285428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AbortSignal.idl 2021-11-08 21:12:36 UTC (rev 285427)
+++ trunk/Source/WebCore/dom/AbortSignal.idl    2021-11-08 21:36:35 UTC (rev 285428)
</span><span class="lines">@@ -26,12 +26,15 @@
</span><span class="cx"> [
</span><span class="cx">     CustomIsReachable,
</span><span class="cx">     Exposed=(Window,Worker),
</span><ins>+    JSCustomMarkFunction,
</ins><span class="cx">     PrivateIdentifier,
</span><span class="cx">     PublicIdentifier
</span><span class="cx"> ] interface AbortSignal : EventTarget {
</span><span class="cx">     [PrivateIdentifier] static boolean whenSignalAborted(AbortSignal object, AbortAlgorithm algorithm);
</span><span class="cx"> 
</span><del>-    [NewObject, CallWith=ScriptExecutionContext] static AbortSignal abort();
</del><ins>+    [NewObject, CallWith=ScriptExecutionContext&GlobalObject] static AbortSignal abort(optional any reason);
</ins><span class="cx">     readonly attribute boolean aborted;
</span><ins>+    readonly attribute any reason;
+
</ins><span class="cx">     attribute EventHandler onabort;
</span><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>