Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Media element never populates its UA shadow if it was initially creat…
…ed in a document without browsing context https://bugs.webkit.org/show_bug.cgi?id=222657 <rdar://problem/75266631> Reviewed by Eric Carlson. Previously, `HTMLMediaElement` relied on `didAddUserAgentShadowRoot` to call the JS `createControls` that actually populates the UA shadow root. This did not work with `adoptNode` because in that case the UA shadow root already existed and was already attached to the `<video>`, so it was not called. Rather than rely on this single path to set up everything, instead have a `ControlsState` enum that `HTMLMediaElement` can internally reason about to decide whether or not it needs to inject the JS that creates `createControls` and then call it. This also has the added benefit of having those two steps now be in the same place, whereas before they were split across two unrelated functions. * Source/WebCore/html/HTMLMediaElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::updateCaptionContainer): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::configureTextTrackDisplay): (WebCore::HTMLMediaElement::updateTextTrackDisplay): (WebCore::HTMLMediaElement::updateTextTrackRepresentationImageIfNeeded): (WebCore::HTMLMediaElement::configureMediaControls): (WebCore::HTMLMediaElement::ensureMediaControls): Added. (WebCore::HTMLMediaElement::getCurrentMediaControlsStatus): (WebCore::HTMLMediaElement::ensureMediaControlsShadowRoot): Deleted. (WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript): Deleted. (WebCore::HTMLMediaElement::didAddUserAgentShadowRoot): Deleted. * LayoutTests/media/audio-controls-adoptNode.html: Added. * LayoutTests/media/audio-controls-adoptNode-expected.txt: Added. * LayoutTests/media/video-controls-adoptNode.html: Added. * LayoutTests/media/video-controls-adoptNode-expected.txt: Added. Canonical link: https://commits.webkit.org/253225@main
- Loading branch information
Showing
6 changed files
with
83 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Test that UA shadow from 'controls' attribute is still populated when using adoptNode. | ||
|
||
EXPECTED (mediaElement.getAttribute('controls') == '') OK | ||
EXPECTED (shadow?.childNodes.length > '0') OK | ||
END OF 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<p>Test that UA shadow from 'controls' attribute is still populated when using adoptNode.<p> | ||
<script src=video-test.js></script> | ||
<script> | ||
var parser = new DOMParser; | ||
mediaElement = parser.parseFromString("<audio controls></audio>", "text/html").body.children[0]; | ||
|
||
document.body.appendChild(document.adoptNode(mediaElement)); | ||
|
||
testExpected("mediaElement.getAttribute('controls')", ""); | ||
|
||
var shadow = window.internals?.shadowRoot(mediaElement); | ||
testExpected("shadow?.childNodes.length", 0, ">"); | ||
|
||
endTest(); | ||
|
||
</script> |
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,6 @@ | ||
Test that UA shadow from 'controls' attribute is still populated when using adoptNode. | ||
|
||
EXPECTED (mediaElement.getAttribute('controls') == '') OK | ||
EXPECTED (shadow?.childNodes.length > '0') OK | ||
END OF 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<p>Test that UA shadow from 'controls' attribute is still populated when using adoptNode.<p> | ||
<script src=video-test.js></script> | ||
<script> | ||
var parser = new DOMParser; | ||
mediaElement = parser.parseFromString("<video controls></video>", "text/html").body.children[0]; | ||
|
||
document.body.appendChild(document.adoptNode(mediaElement)); | ||
|
||
testExpected("mediaElement.getAttribute('controls')", ""); | ||
|
||
var shadow = window.internals?.shadowRoot(mediaElement); | ||
testExpected("shadow?.childNodes.length", 0, ">"); | ||
|
||
endTest(); | ||
|
||
</script> |
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