forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support AbortSignal in addEventListenerOptions to unsubscribe from ev…
…ents https://bugs.webkit.org/show_bug.cgi?id=218753 <rdar://problem/71258012> Reviewed by Darin Adler. LayoutTests/imported/w3c: Import test coverage from WPT. * web-platform-tests/dom/events/AddEventListenerOptions-signal.any-expected.txt: Added. * web-platform-tests/dom/events/AddEventListenerOptions-signal.any.html: Added. * web-platform-tests/dom/events/AddEventListenerOptions-signal.any.js: Added. * web-platform-tests/dom/events/AddEventListenerOptions-signal.any.worker-expected.txt: Added. * web-platform-tests/dom/events/AddEventListenerOptions-signal.any.worker.html: Added. * web-platform-tests/dom/events/w3c-import.log: Source/WebCore: Support AbortSignal in addEventListenerOptions to unsubscribe from events: - whatwg/dom#911 - whatwg/dom#919 Blink already added support for this. Tests: imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-signal.any.html imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-signal.any.worker.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Headers.cmake: * Modules/async-clipboard/Clipboard.h: * Modules/encryptedmedia/MediaKeySession.h: * Modules/indexeddb/IDBRequest.h: * Modules/mediastream/MediaDevices.h: * Modules/mediastream/RTCPeerConnection.h: * Modules/paymentrequest/PaymentRequest.h: * Modules/speech/SpeechRecognition.h: * Modules/webaudio/BaseAudioContext.h: * Modules/webgpu/WebGPUDevice.h: * Modules/webxr/WebXRSystem.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/WebAnimation.h: * css/MediaQueryList.cpp: (WebCore::MediaQueryList::addListener): (WebCore::MediaQueryList::removeListener): * css/MediaQueryList.h: * dom/AbortSignal.h: * dom/AddEventListenerOptions.h: Copied from Source/WebCore/loader/appcache/DOMApplicationCache.h. (WebCore::AddEventListenerOptions::AddEventListenerOptions): * dom/AddEventListenerOptions.idl: Copied from Source/WebCore/loader/appcache/DOMApplicationCache.h. * dom/EventListener.h: * dom/EventListenerMap.cpp: * dom/EventListenerOptions.h: Copied from Source/WebCore/loader/appcache/DOMApplicationCache.h. (WebCore::EventListenerOptions::EventListenerOptions): * dom/EventListenerOptions.idl: Copied from Source/WebCore/loader/appcache/DOMApplicationCache.h. * dom/EventTarget.cpp: (WebCore::EventTarget::addEventListener): (WebCore::EventTarget::removeEventListenerForBindings): (WebCore::EventTarget::removeEventListener): (WebCore::EventTarget::setAttributeEventListener): (WebCore::EventTarget::innerInvokeEventListeners): * dom/EventTarget.h: (WebCore::EventTarget::removeEventListener): * dom/EventTarget.idl: * dom/MessagePort.cpp: (WebCore::MessagePort::MessagePort): (WebCore::MessagePort::removeEventListener): * dom/MessagePort.h: * dom/Node.cpp: (WebCore::tryAddEventListener): (WebCore::tryRemoveEventListener): (WebCore::Node::removeEventListener): * dom/Node.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::removeEventListener): * html/HTMLMediaElement.h: * html/ImageDocument.cpp: * html/track/TextTrackCue.h: * inspector/agents/InspectorDOMAgent.cpp: * loader/appcache/DOMApplicationCache.h: * page/DOMWindow.cpp: (WebCore::DOMWindow::removeEventListener): * page/DOMWindow.h: * platform/cocoa/PlaybackSessionModelMediaElement.mm: * platform/cocoa/VideoFullscreenModelVideoElement.mm: * svg/SVGElement.cpp: (WebCore::SVGElement::removeEventListener): * svg/SVGElement.h: * svg/SVGTRefElement.cpp: * svg/animation/SVGSMILElement.cpp: * testing/Internals.cpp: * workers/service/ServiceWorkerContainer.h: Source/WebKit: Minor build fixes. * WebProcess/Plugins/PDF/PDFPluginAnnotation.mm: Source/WebKitLegacy/mac: Minor build fixes. * DOM/DOMNode.mm: Source/WTF: Add initializeWeakPtrFactory() protection function to CanMakeWeakPtr so that a subclass can eagerly initialize the WeakPtrFactory even if it does not subclass WeakPtrFactory<T, WeakPtrFactoryInitialization::Eager>. MessagePort used to subclass WeakPtrFactory<T, WeakPtrFactoryInitialization::Eager> for thread-safety reason but it now subclasses WeakPtrFactory<T, WeakPtrFactoryInitialization::Lazy> via EventTarget. * wtf/WeakPtr.h: (WTF::CanMakeWeakPtr::initializeWeakPtrFactory): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@271806 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
b408e42
commit ac3e4a9
Showing
66 changed files
with
567 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
2021-01-25 Chris Dumez <[email protected]> | ||
|
||
Support AbortSignal in addEventListenerOptions to unsubscribe from events | ||
https://bugs.webkit.org/show_bug.cgi?id=218753 | ||
<rdar://problem/71258012> | ||
|
||
Reviewed by Darin Adler. | ||
|
||
Import test coverage from WPT. | ||
|
||
* web-platform-tests/dom/events/AddEventListenerOptions-signal.any-expected.txt: Added. | ||
* web-platform-tests/dom/events/AddEventListenerOptions-signal.any.html: Added. | ||
* web-platform-tests/dom/events/AddEventListenerOptions-signal.any.js: Added. | ||
* web-platform-tests/dom/events/AddEventListenerOptions-signal.any.worker-expected.txt: Added. | ||
* web-platform-tests/dom/events/AddEventListenerOptions-signal.any.worker.html: Added. | ||
* web-platform-tests/dom/events/w3c-import.log: | ||
|
||
2021-01-25 Sam Weinig <[email protected]> | ||
|
||
Import css/css-color tests from WPT | ||
|
11 changes: 11 additions & 0 deletions
11
...mported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-signal.any-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
PASS Passing an AbortSignal to addEventListener options should allow removing a listener | ||
PASS Passing an AbortSignal to addEventListener does not prevent removeEventListener | ||
PASS Passing an AbortSignal to addEventListener works with the once flag | ||
PASS Removing a once listener works with a passed signal | ||
PASS Passing an AbortSignal to multiple listeners | ||
PASS Passing an AbortSignal to addEventListener works with the capture flag | ||
PASS Aborting from a listener does not call future listeners | ||
PASS Adding then aborting a listener in another listener does not call it | ||
PASS Aborting from a nested listener should remove it | ||
|
1 change: 1 addition & 0 deletions
1
...tTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-signal.any.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
133 changes: 133 additions & 0 deletions
133
LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-signal.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
'use strict'; | ||
|
||
test(function() { | ||
let count = 0; | ||
function handler() { | ||
count++; | ||
} | ||
const et = new EventTarget(); | ||
const controller = new AbortController(); | ||
et.addEventListener('test', handler, { signal: controller.signal }); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 1, "Adding a signal still adds a listener"); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 2, "The listener was not added with the once flag"); | ||
controller.abort(); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 2, "Aborting on the controller removes the listener"); | ||
et.addEventListener('test', handler, { signal: controller.signal }); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 2, "Passing an aborted signal never adds the handler"); | ||
}, "Passing an AbortSignal to addEventListener options should allow removing a listener"); | ||
|
||
test(function() { | ||
let count = 0; | ||
function handler() { | ||
count++; | ||
} | ||
const et = new EventTarget(); | ||
const controller = new AbortController(); | ||
et.addEventListener('test', handler, { signal: controller.signal }); | ||
et.removeEventListener('test', handler); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 0, "The listener was still removed"); | ||
}, "Passing an AbortSignal to addEventListener does not prevent removeEventListener"); | ||
|
||
test(function() { | ||
let count = 0; | ||
function handler() { | ||
count++; | ||
} | ||
const et = new EventTarget(); | ||
const controller = new AbortController(); | ||
et.addEventListener('test', handler, { signal: controller.signal, once: true }); | ||
controller.abort(); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 0, "The listener was still removed"); | ||
}, "Passing an AbortSignal to addEventListener works with the once flag"); | ||
|
||
test(function() { | ||
let count = 0; | ||
function handler() { | ||
count++; | ||
} | ||
const et = new EventTarget(); | ||
const controller = new AbortController(); | ||
et.addEventListener('test', handler, { signal: controller.signal, once: true }); | ||
et.removeEventListener('test', handler); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 0, "The listener was still removed"); | ||
}, "Removing a once listener works with a passed signal"); | ||
|
||
test(function() { | ||
let count = 0; | ||
function handler() { | ||
count++; | ||
} | ||
const et = new EventTarget(); | ||
const controller = new AbortController(); | ||
et.addEventListener('first', handler, { signal: controller.signal, once: true }); | ||
et.addEventListener('second', handler, { signal: controller.signal, once: true }); | ||
controller.abort(); | ||
et.dispatchEvent(new Event('first')); | ||
et.dispatchEvent(new Event('second')); | ||
assert_equals(count, 0, "The listener was still removed"); | ||
}, "Passing an AbortSignal to multiple listeners"); | ||
|
||
test(function() { | ||
let count = 0; | ||
function handler() { | ||
count++; | ||
} | ||
const et = new EventTarget(); | ||
const controller = new AbortController(); | ||
et.addEventListener('test', handler, { signal: controller.signal, capture: true }); | ||
controller.abort(); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 0, "The listener was still removed"); | ||
}, "Passing an AbortSignal to addEventListener works with the capture flag"); | ||
|
||
test(function() { | ||
let count = 0; | ||
function handler() { | ||
count++; | ||
} | ||
const et = new EventTarget(); | ||
const controller = new AbortController(); | ||
et.addEventListener('test', () => { | ||
controller.abort(); | ||
}, { signal: controller.signal }); | ||
et.addEventListener('test', handler, { signal: controller.signal }); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 0, "The listener was still removed"); | ||
}, "Aborting from a listener does not call future listeners"); | ||
|
||
test(function() { | ||
let count = 0; | ||
function handler() { | ||
count++; | ||
} | ||
const et = new EventTarget(); | ||
const controller = new AbortController(); | ||
et.addEventListener('test', () => { | ||
et.addEventListener('test', handler, { signal: controller.signal }); | ||
controller.abort(); | ||
}, { signal: controller.signal }); | ||
et.dispatchEvent(new Event('test')); | ||
assert_equals(count, 0, "The listener was still removed"); | ||
}, "Adding then aborting a listener in another listener does not call it"); | ||
|
||
test(function() { | ||
const et = new EventTarget(); | ||
const ac = new AbortController(); | ||
let count = 0; | ||
et.addEventListener('foo', () => { | ||
et.addEventListener('foo', () => { | ||
count++; | ||
if (count > 5) ac.abort(); | ||
et.dispatchEvent(new Event('foo')); | ||
}, { signal: ac.signal }); | ||
et.dispatchEvent(new Event('foo')); | ||
}, { once: true }); | ||
et.dispatchEvent(new Event('foo')); | ||
}, "Aborting from a nested listener should remove it"); |
11 changes: 11 additions & 0 deletions
11
.../w3c/web-platform-tests/dom/events/AddEventListenerOptions-signal.any.worker-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
PASS Passing an AbortSignal to addEventListener options should allow removing a listener | ||
PASS Passing an AbortSignal to addEventListener does not prevent removeEventListener | ||
PASS Passing an AbortSignal to addEventListener works with the once flag | ||
PASS Removing a once listener works with a passed signal | ||
PASS Passing an AbortSignal to multiple listeners | ||
PASS Passing an AbortSignal to addEventListener works with the capture flag | ||
PASS Aborting from a listener does not call future listeners | ||
PASS Adding then aborting a listener in another listener does not call it | ||
PASS Aborting from a nested listener should remove it | ||
|
1 change: 1 addition & 0 deletions
1
...imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-signal.any.worker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- This file is required for WebKit test infrastructure to run the templated test --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
2021-01-25 Chris Dumez <[email protected]> | ||
|
||
Support AbortSignal in addEventListenerOptions to unsubscribe from events | ||
https://bugs.webkit.org/show_bug.cgi?id=218753 | ||
<rdar://problem/71258012> | ||
|
||
Reviewed by Darin Adler. | ||
|
||
Add initializeWeakPtrFactory() protection function to CanMakeWeakPtr so that a subclass | ||
can eagerly initialize the WeakPtrFactory even if it does not subclass | ||
WeakPtrFactory<T, WeakPtrFactoryInitialization::Eager>. MessagePort used to subclass | ||
WeakPtrFactory<T, WeakPtrFactoryInitialization::Eager> for thread-safety reason but it | ||
now subclasses WeakPtrFactory<T, WeakPtrFactoryInitialization::Lazy> via EventTarget. | ||
|
||
* wtf/WeakPtr.h: | ||
(WTF::CanMakeWeakPtr::initializeWeakPtrFactory): | ||
|
||
2021-01-25 Per Arne Vollan <[email protected]> | ||
|
||
[macOS] Fix OS version check for ENABLE_SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,89 @@ | ||
2021-01-25 Chris Dumez <[email protected]> | ||
|
||
Support AbortSignal in addEventListenerOptions to unsubscribe from events | ||
https://bugs.webkit.org/show_bug.cgi?id=218753 | ||
<rdar://problem/71258012> | ||
|
||
Reviewed by Darin Adler. | ||
|
||
Support AbortSignal in addEventListenerOptions to unsubscribe from events: | ||
- https://github.com/whatwg/dom/issues/911 | ||
- https://github.com/whatwg/dom/pull/919 | ||
|
||
Blink already added support for this. | ||
|
||
Tests: imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-signal.any.html | ||
imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-signal.any.worker.html | ||
|
||
* CMakeLists.txt: | ||
* DerivedSources-input.xcfilelist: | ||
* DerivedSources-output.xcfilelist: | ||
* DerivedSources.make: | ||
* Headers.cmake: | ||
* Modules/async-clipboard/Clipboard.h: | ||
* Modules/encryptedmedia/MediaKeySession.h: | ||
* Modules/indexeddb/IDBRequest.h: | ||
* Modules/mediastream/MediaDevices.h: | ||
* Modules/mediastream/RTCPeerConnection.h: | ||
* Modules/paymentrequest/PaymentRequest.h: | ||
* Modules/speech/SpeechRecognition.h: | ||
* Modules/webaudio/BaseAudioContext.h: | ||
* Modules/webgpu/WebGPUDevice.h: | ||
* Modules/webxr/WebXRSystem.h: | ||
* Sources.txt: | ||
* WebCore.xcodeproj/project.pbxproj: | ||
* animation/WebAnimation.h: | ||
* css/MediaQueryList.cpp: | ||
(WebCore::MediaQueryList::addListener): | ||
(WebCore::MediaQueryList::removeListener): | ||
* css/MediaQueryList.h: | ||
* dom/AbortSignal.h: | ||
* dom/AddEventListenerOptions.h: Copied from Source/WebCore/loader/appcache/DOMApplicationCache.h. | ||
(WebCore::AddEventListenerOptions::AddEventListenerOptions): | ||
* dom/AddEventListenerOptions.idl: Copied from Source/WebCore/loader/appcache/DOMApplicationCache.h. | ||
* dom/EventListener.h: | ||
* dom/EventListenerMap.cpp: | ||
* dom/EventListenerOptions.h: Copied from Source/WebCore/loader/appcache/DOMApplicationCache.h. | ||
(WebCore::EventListenerOptions::EventListenerOptions): | ||
* dom/EventListenerOptions.idl: Copied from Source/WebCore/loader/appcache/DOMApplicationCache.h. | ||
* dom/EventTarget.cpp: | ||
(WebCore::EventTarget::addEventListener): | ||
(WebCore::EventTarget::removeEventListenerForBindings): | ||
(WebCore::EventTarget::removeEventListener): | ||
(WebCore::EventTarget::setAttributeEventListener): | ||
(WebCore::EventTarget::innerInvokeEventListeners): | ||
* dom/EventTarget.h: | ||
(WebCore::EventTarget::removeEventListener): | ||
* dom/EventTarget.idl: | ||
* dom/MessagePort.cpp: | ||
(WebCore::MessagePort::MessagePort): | ||
(WebCore::MessagePort::removeEventListener): | ||
* dom/MessagePort.h: | ||
* dom/Node.cpp: | ||
(WebCore::tryAddEventListener): | ||
(WebCore::tryRemoveEventListener): | ||
(WebCore::Node::removeEventListener): | ||
* dom/Node.h: | ||
* html/HTMLMediaElement.cpp: | ||
(WebCore::HTMLMediaElement::removeEventListener): | ||
* html/HTMLMediaElement.h: | ||
* html/ImageDocument.cpp: | ||
* html/track/TextTrackCue.h: | ||
* inspector/agents/InspectorDOMAgent.cpp: | ||
* loader/appcache/DOMApplicationCache.h: | ||
* page/DOMWindow.cpp: | ||
(WebCore::DOMWindow::removeEventListener): | ||
* page/DOMWindow.h: | ||
* platform/cocoa/PlaybackSessionModelMediaElement.mm: | ||
* platform/cocoa/VideoFullscreenModelVideoElement.mm: | ||
* svg/SVGElement.cpp: | ||
(WebCore::SVGElement::removeEventListener): | ||
* svg/SVGElement.h: | ||
* svg/SVGTRefElement.cpp: | ||
* svg/animation/SVGSMILElement.cpp: | ||
* testing/Internals.cpp: | ||
* workers/service/ServiceWorkerContainer.h: | ||
|
||
2021-01-25 John Wilander <[email protected]> | ||
|
||
PCM: Use different well-known locations for triggering and reporting attribution | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.