Changeset 274773 in webkit
- Timestamp:
- Mar 22, 2021 12:25:16 PM (16 months ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.js (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.worker-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/fetch/FetchRequest.cpp (modified) (4 diffs)
-
Source/WebCore/dom/AbortController.cpp (modified) (1 diff)
-
Source/WebCore/dom/AbortSignal.cpp (modified) (5 diffs)
-
Source/WebCore/dom/AbortSignal.h (modified) (2 diffs)
-
Source/WebCore/dom/AbortSignal.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r274748 r274773 1 2021-03-22 Chris Dumez <cdumez@apple.com> 2 3 Implement AbortSignal.abort() 4 https://bugs.webkit.org/show_bug.cgi?id=223071 5 <rdar://problem/75575483> 6 7 Reviewed by Darin Adler. 8 9 Resync WPT test from upstream a8cbe9c712ad032d36 to gain test coverage. 10 11 * web-platform-tests/dom/abort/event.any-expected.txt: 12 * web-platform-tests/dom/abort/event.any.js: 13 * web-platform-tests/dom/abort/event.any.worker-expected.txt: 14 1 15 2021-03-19 Chris Dumez <cdumez@apple.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any-expected.txt
r267660 r274773 5 5 PASS event handler should not be called if added after controller.abort() 6 6 PASS the abort event should have the right properties 7 PASS the AbortSignal.abort() static returns an already aborted signal 7 8 -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.js
r229544 r274773 65 65 }, "the abort event should have the right properties"); 66 66 67 test(t => { 68 const signal = AbortSignal.abort(); 69 assert_true(signal.aborted); 70 }, "the AbortSignal.abort() static returns an already aborted signal"); 71 67 72 done(); -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/abort/event.any.worker-expected.txt
r267660 r274773 5 5 PASS event handler should not be called if added after controller.abort() 6 6 PASS the abort event should have the right properties 7 PASS the AbortSignal.abort() static returns an already aborted signal 7 8 -
trunk/Source/WebCore/ChangeLog
r274772 r274773 1 2021-03-22 Chris Dumez <cdumez@apple.com> 2 3 Implement AbortSignal.abort() 4 https://bugs.webkit.org/show_bug.cgi?id=223071 5 <rdar://problem/75575483> 6 7 Reviewed by Darin Adler. 8 9 Implement AbortSignal.abort() which creates and returns an already aborted AbortSignal: 10 - https://github.com/whatwg/dom/pull/960 11 - https://github.com/web-platform-tests/wpt/pull/28003 12 13 No new tests, covered by updated test. 14 15 * dom/AbortSignal.cpp: 16 (WebCore::AbortSignal::createAborted): 17 (WebCore::AbortSignal::AbortSignal): 18 * dom/AbortSignal.h: 19 * dom/AbortSignal.idl: 20 1 21 2021-03-22 Wenson Hsieh <wenson_hsieh@apple.com> 2 22 -
trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp
r264853 r274773 180 180 if (init.signal) { 181 181 if (auto* signal = JSAbortSignal::toWrapped(scriptExecutionContext()->vm(), init.signal)) 182 m_signal-> follow(*signal);182 m_signal->signalFollow(*signal); 183 183 else if (!init.signal.isUndefinedOrNull()) { 184 184 if (auto exception = processInvalidSignal(*scriptExecutionContext())) … … 215 215 if (init.signal && !init.signal.isUndefined()) { 216 216 if (auto* signal = JSAbortSignal::toWrapped(scriptExecutionContext()->vm(), init.signal)) 217 m_signal-> follow(*signal);217 m_signal->signalFollow(*signal); 218 218 else if (!init.signal.isNull()) { 219 219 if (auto exception = processInvalidSignal(*scriptExecutionContext())) … … 222 222 223 223 } else 224 m_signal-> follow(input.m_signal.get());224 m_signal->signalFollow(input.m_signal.get()); 225 225 226 226 if (init.hasMembers()) { … … 325 325 auto clone = adoptRef(*new FetchRequest(context, WTF::nullopt, FetchHeaders::create(m_headers.get()), ResourceRequest { m_request }, FetchOptions { m_options}, String { m_referrer })); 326 326 clone->cloneBody(*this); 327 clone->m_signal-> follow(m_signal);327 clone->m_signal->signalFollow(m_signal); 328 328 return clone; 329 329 } -
trunk/Source/WebCore/dom/AbortController.cpp
r243887 r274773 53 53 void AbortController::abort() 54 54 { 55 m_signal-> abort();55 m_signal->signalAbort(); 56 56 } 57 57 -
trunk/Source/WebCore/dom/AbortSignal.cpp
r266177 r274773 42 42 } 43 43 44 AbortSignal::AbortSignal(ScriptExecutionContext& context) 44 // https://dom.spec.whatwg.org/#dom-abortsignal-abort 45 Ref<AbortSignal> AbortSignal::abort(ScriptExecutionContext& context) 46 { 47 return adoptRef(*new AbortSignal(context, Aborted::Yes)); 48 } 49 50 AbortSignal::AbortSignal(ScriptExecutionContext& context, Aborted aborted) 45 51 : ContextDestructionObserver(&context) 52 , m_aborted(aborted == Aborted::Yes) 46 53 { 47 54 } 48 55 49 56 // https://dom.spec.whatwg.org/#abortsignal-signal-abort 50 void AbortSignal:: abort()57 void AbortSignal::signalAbort() 51 58 { 52 59 // 1. If signal's aborted flag is set, then return. … … 58 65 59 66 auto protectedThis = makeRef(*this); 60 auto algorithms = WTFMove(m_algorithms);67 auto algorithms = std::exchange(m_algorithms, { }); 61 68 for (auto& algorithm : algorithms) 62 69 algorithm(); … … 67 74 68 75 // https://dom.spec.whatwg.org/#abortsignal-follow 69 void AbortSignal:: follow(AbortSignal& signal)76 void AbortSignal::signalFollow(AbortSignal& signal) 70 77 { 71 78 if (aborted()) … … 73 80 74 81 if (signal.aborted()) { 75 abort();82 signalAbort(); 76 83 return; 77 84 } … … 80 87 m_followingSignal = makeWeakPtr(signal); 81 88 signal.addAlgorithm([weakThis = makeWeakPtr(this)] { 82 if (!weakThis) 83 return; 84 weakThis->abort(); 89 if (weakThis) 90 weakThis->signalAbort(); 85 91 }); 86 92 } -
trunk/Source/WebCore/dom/AbortSignal.h
r271806 r274773 44 44 static Ref<AbortSignal> create(ScriptExecutionContext&); 45 45 46 static Ref<AbortSignal> abort(ScriptExecutionContext&); 47 46 48 static bool whenSignalAborted(AbortSignal&, Ref<AbortAlgorithm>&&); 47 49 48 void abort(); 50 void signalAbort(); 51 void signalFollow(AbortSignal&); 49 52 50 53 bool aborted() const { return m_aborted; } … … 56 59 void addAlgorithm(Algorithm&& algorithm) { m_algorithms.append(WTFMove(algorithm)); } 57 60 58 void follow(AbortSignal&);59 60 61 bool isFollowingSignal() const { return !!m_followingSignal; } 61 62 62 63 private: 63 explicit AbortSignal(ScriptExecutionContext&); 64 enum class Aborted : bool { No, Yes }; 65 explicit AbortSignal(ScriptExecutionContext&, Aborted = Aborted::No); 64 66 67 // EventTarget. 65 68 EventTargetInterface eventTargetInterface() const final { return AbortSignalEventTargetInterfaceType; } 66 69 ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); } -
trunk/Source/WebCore/dom/AbortSignal.idl
r266311 r274773 32 32 [ PrivateIdentifier ] static undefined whenSignalAborted(AbortSignal object, AbortAlgorithm algorithm); 33 33 34 [NewObject, CallWith=ScriptExecutionContext] static AbortSignal abort(); 34 35 readonly attribute boolean aborted; 35 36 attribute EventHandler onabort;
Note: See TracChangeset
for help on using the changeset viewer.