Skip to content

Commit

Permalink
Remove all HTMLMediaElement's tracks event listeners
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267530

Reviewed by Ryosuke Niwa.

When `HTMLMediaElement::removeAllEventListeners()` is called we should
also remove all event listeners of all its tracks.

Combined changes:
* LayoutTests/platform/wpe/TestExpectations:
* LayoutTests/platform/wpe/fullscreen/exit-full-screen-video-crash-expected.txt:
* Source/WebCore/dom/Element.h:
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::removeAllEventListeners):
* Source/WebCore/html/HTMLMediaElement.h:

Canonical link: https://commits.webkit.org/273063@main
  • Loading branch information
obyknovenius committed Jan 16, 2024
1 parent 5739c4b commit 94407ea
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
6 changes: 0 additions & 6 deletions LayoutTests/platform/wpe/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1619,12 +1619,6 @@ webkit.org/b/266577 webgl/2.0.0/conformance2/textures/video/tex-3d-srgb8_alpha8-

webkit.org/b/266671 http/wpt/webcodecs/videoFrame-rect.html [ Failure ]

webkit.org/b/266711 fast/mediastream/microphone-change-while-capturing.html [ Pass Crash ]
webkit.org/b/266711 media/modern-media-controls/audio/audio-controls-styles.html [ Failure Crash ]
webkit.org/b/266711 webrtc/canvas-to-peer-connection.html [ Failure Timeout Crash ]
webkit.org/b/266711 webrtc/release-after-getting-track.html [ Pass Crash ]
webkit.org/b/266711 fast/mediastream/applyConstraints-deviceId.html [ Pass Crash ]
webkit.org/b/266711 fast/mediastream/MediaStream-video-element-enter-background.html [ Failure Pass Crash ]
webkit.org/b/266711 fast/editing/create-link-inline-style-change-crash-001.html [ Pass Crash ]

fast/dom/no-scroll-when-command-click-fragment-URL.html [ Failure ]
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state.
CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Type error

2 changes: 1 addition & 1 deletion Source/WebCore/dom/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ class Element : public ContainerNode {
InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) override;
void removedFromAncestor(RemovalType, ContainerNode&) override;
void childrenChanged(const ChildChange&) override;
void removeAllEventListeners() final;
void removeAllEventListeners() override;
virtual void parserDidSetAttributes();

void setTabIndexExplicitly(std::optional<int>);
Expand Down
14 changes: 14 additions & 0 deletions Source/WebCore/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,20 @@ bool HTMLMediaElement::isInteractiveContent() const
return controls();
}

void HTMLMediaElement::removeAllEventListeners()
{
Element::removeAllEventListeners();

if (m_audioTracks)
m_audioTracks->removeAllEventListeners();

if (m_textTracks)
m_textTracks->removeAllEventListeners();

if (m_videoTracks)
m_videoTracks->removeAllEventListeners();
}

void HTMLMediaElement::attributeChanged(const QualifiedName& name, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason attributeModificationReason)
{
switch (name.nodeName()) {
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/html/HTMLMediaElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ class HTMLMediaElement
HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
virtual ~HTMLMediaElement();

void removeAllEventListeners() final;

void attributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason) override;
void finishParsingChildren() override;
bool isURLAttribute(const Attribute&) const override;
Expand Down

0 comments on commit 94407ea

Please sign in to comment.