<!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>[279217] 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/279217">279217</a></dd>
<dt>Author</dt> <dd>eocanha@igalia.com</dd>
<dt>Date</dt> <dd>2021-06-24 02:31:16 -0700 (Thu, 24 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] media/muted-video-is-playing-audio.html is timing out
https://bugs.webkit.org/show_bug.cgi?id=208321

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

Added setPageMediaVolume() API to set the Page mediaVolume. This was 0
by default and a way to set it to a non-zero value was needed in order
to prevent a zero effectiveVolume in HTMLMediaElement.

* testing/Internals.cpp:
(WebCore::Internals::setPageMediaVolume): Set the Page mediaVolume.
* testing/Internals.h: Added setPageMediaVolume().
* testing/Internals.idl: Ditto.

Tools:

Set the WebKitTestRunnerWPE application name on user-agent to ease the
detection of the WPE port from the layout tests using the isWPE()
function in platform-helper.js.

* WebKitTestRunner/wpe/TestControllerWPE.cpp:
(WTR::TestController::platformConfigureViewForTest): Set WebKitTestRunnerWPE application name on user-agent.

LayoutTests:

Changed the test to set a non-zero mediaVolume, because a zero one
(default value set by TestController::resetStateToConsistentValues())
would multiply any other volume in HTMLMediaElement::effectiveVolume(),
cause a zero effectiveVolume (being considered in practice as "no audio" by
HTMLMediaElement::mediaState()) and prevent the IsPlayingAudio MediaState
being set.

Also, adapted the test to still expect IsPlayingAudio after mute on the
glib ports (GTK & WPE), since on those ports a muted video is expected to
report IsPlayingAudio, as per the HTMLMediaElement::mediaState() source
code comments.

* media/muted-video-is-playing-audio.html: Test changed as described above.
* platform/glib/media/muted-video-is-playing-audio-expected.txt: Added expectation for glib port.
* resources/platform-helper.js:
(isGtk): Clarified where the GTK user-agent string comes from.
(isWPE): New function to check if a WPE port is being used.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsmediamutedvideoisplayingaudiohtml">trunk/LayoutTests/media/muted-video-is-playing-audio.html</a></li>
<li><a href="#trunkLayoutTestsresourcesplatformhelperjs">trunk/LayoutTests/resources/platform-helper.js</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerwpeTestControllerWPEcpp">trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformglibmediamutedvideoisplayingaudioexpectedtxt">trunk/LayoutTests/platform/glib/media/muted-video-is-playing-audio-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (279216 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-06-24 08:31:48 UTC (rev 279216)
+++ trunk/LayoutTests/ChangeLog 2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2021-06-24  Enrique Ocaña González  <eocanha@igalia.com>
+
+        [GTK] media/muted-video-is-playing-audio.html is timing out
+        https://bugs.webkit.org/show_bug.cgi?id=208321
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Changed the test to set a non-zero mediaVolume, because a zero one
+        (default value set by TestController::resetStateToConsistentValues())
+        would multiply any other volume in HTMLMediaElement::effectiveVolume(),
+        cause a zero effectiveVolume (being considered in practice as "no audio" by
+        HTMLMediaElement::mediaState()) and prevent the IsPlayingAudio MediaState
+        being set.
+
+        Also, adapted the test to still expect IsPlayingAudio after mute on the
+        glib ports (GTK & WPE), since on those ports a muted video is expected to
+        report IsPlayingAudio, as per the HTMLMediaElement::mediaState() source
+        code comments.
+
+        * media/muted-video-is-playing-audio.html: Test changed as described above.
+        * platform/glib/media/muted-video-is-playing-audio-expected.txt: Added expectation for glib port.
+        * resources/platform-helper.js:
+        (isGtk): Clarified where the GTK user-agent string comes from.
+        (isWPE): New function to check if a WPE port is being used.
+
</ins><span class="cx"> 2021-06-23  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, mark imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-MediaElement-disabled-audio-is-silence.https.html as flaky on iOS.
</span></span></pre></div>
<a id="trunkLayoutTestsmediamutedvideoisplayingaudiohtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/muted-video-is-playing-audio.html (279216 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/muted-video-is-playing-audio.html        2021-06-24 08:31:48 UTC (rev 279216)
+++ trunk/LayoutTests/media/muted-video-is-playing-audio.html   2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -2,6 +2,7 @@
</span><span class="cx"> <html>
</span><span class="cx">     <head>
</span><span class="cx">         <script src="../resources/js-test-pre.js"></script>
</span><ins>+        <script src="../resources/platform-helper.js"></script>
</ins><span class="cx">     </head>
</span><span class="cx">     <body>
</span><span class="cx">         <video src="content/audio-tracks.mp4" controls autoplay loop></video>
</span><span class="lines">@@ -13,8 +14,12 @@
</span><span class="cx">             jsTestIsAsync = true;
</span><span class="cx"> 
</span><span class="cx">             // Un-mute audio on the page before starting the test.
</span><del>-            if (window.internals)
</del><ins>+            if (window.internals) {
</ins><span class="cx">                 internals.setPageMuted("");
</span><ins>+                // TestController::resetStateToConsistentValues() initializes mediaVolume to 0, which in practice mutes the audio and
+                // interferes with this test. Let's use some quiet non-zero value.
+                internals.setPageMediaVolume(0.01);
+            }
</ins><span class="cx"> 
</span><span class="cx">             function testUnmutingVideo()
</span><span class="cx">             {
</span><span class="lines">@@ -25,9 +30,18 @@
</span><span class="cx">             function testMutingVideo()
</span><span class="cx">             {
</span><span class="cx">                 run("video.muted = true");
</span><del>-                shouldBecomeEqual("window.internals.pageMediaState().includes('IsPlayingAudio')", "false", testUnmutingVideo);
</del><ins>+                // For GStreamer ports the semantics of IsPlayingAudio slightly differ from Apple ports. The
+                // webkit_web_view_is_playing_audio() API is expected to return true if a page is producing
+                // audio even though it might be muted. See HTMLMediaElement::mediaState() implementation.
+                var isPlayingAudioExpectedAfterMute = (isGtk() || isWPE()) ? "true" : "false";
+                shouldBecomeEqual("window.internals.pageMediaState().includes('IsPlayingAudio')", isPlayingAudioExpectedAfterMute, testUnmutingVideo);
</ins><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            video.addEventListener('playing', function setInitialVolume() {
+                video.volume = 1;
+                video.removeEventListener('playing', setInitialVolume);
+            });
+
</ins><span class="cx">             shouldBecomeEqual("window.internals.pageMediaState().includes('IsPlayingAudio')", "true", testMutingVideo);
</span><span class="cx">         </script>
</span><span class="cx">         <script src="../resources/js-test-post.js"></script>
</span></span></pre></div>
<a id="trunkLayoutTestsplatformglibmediamutedvideoisplayingaudioexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/glib/media/muted-video-is-playing-audio-expected.txt (0 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/glib/media/muted-video-is-playing-audio-expected.txt                          (rev 0)
+++ trunk/LayoutTests/platform/glib/media/muted-video-is-playing-audio-expected.txt     2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+Testing that muting a video element should result in page's audio playing state to become false
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.internals.pageMediaState().includes('IsPlayingAudio') became true
+PASS window.internals.pageMediaState().includes('IsPlayingAudio') became true
+PASS window.internals.pageMediaState().includes('IsPlayingAudio') became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+RUN(video.muted = true)
+RUN(video.muted = false)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsresourcesplatformhelperjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/resources/platform-helper.js (279216 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/resources/platform-helper.js   2021-06-24 08:31:48 UTC (rev 279216)
+++ trunk/LayoutTests/resources/platform-helper.js      2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -1,8 +1,15 @@
</span><span class="cx"> function isGtk()
</span><span class="cx"> {
</span><ins>+    // Set in Tools/WebKitTestRunner/gtk/TestControllerGTK.cpp.
</ins><span class="cx">     return navigator.userAgent.includes("WebKitTestRunnerGTK");
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function isWPE()
+{
+    // Set in Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp.
+    return navigator.userAgent.includes("WebKitTestRunnerWPE");
+}
+
</ins><span class="cx"> function videoCanvasPixelComparisonTolerance()
</span><span class="cx"> {
</span><span class="cx">     if (isGtk())
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (279216 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-06-24 08:31:48 UTC (rev 279216)
+++ trunk/Source/WebCore/ChangeLog      2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2021-06-24  Enrique Ocaña González  <eocanha@igalia.com>
+
+        [GTK] media/muted-video-is-playing-audio.html is timing out
+        https://bugs.webkit.org/show_bug.cgi?id=208321
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Added setPageMediaVolume() API to set the Page mediaVolume. This was 0
+        by default and a way to set it to a non-zero value was needed in order
+        to prevent a zero effectiveVolume in HTMLMediaElement.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::setPageMediaVolume): Set the Page mediaVolume.
+        * testing/Internals.h: Added setPageMediaVolume().
+        * testing/Internals.idl: Ditto.
+
</ins><span class="cx"> 2021-06-23  Jean-Yves Avenard  <jya@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Not all uses of AudioToolbox framework use soft linking
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (279216 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp       2021-06-24 08:31:48 UTC (rev 279216)
+++ trunk/Source/WebCore/testing/Internals.cpp  2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -4840,6 +4840,19 @@
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(VIDEO)
</span><span class="cx"> 
</span><ins>+void Internals::setPageMediaVolume(float volume)
+{
+    Document* document = contextDocument();
+    if (!document)
+        return;
+
+    Page* page = document->page();
+    if (!page)
+        return;
+
+    page->setMediaVolume(volume);
+}
+
</ins><span class="cx"> #if !PLATFORM(COCOA)
</span><span class="cx"> 
</span><span class="cx"> String Internals::userVisibleString(const DOMURL& url)
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (279216 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h 2021-06-24 08:31:48 UTC (rev 279216)
+++ trunk/Source/WebCore/testing/Internals.h    2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -756,6 +756,8 @@
</span><span class="cx">     void setMediaControlsHidePlaybackRates(HTMLMediaElement&, bool);
</span><span class="cx"> #endif // ENABLE(VIDEO)
</span><span class="cx"> 
</span><ins>+    void setPageMediaVolume(float);
+
</ins><span class="cx">     String userVisibleString(const DOMURL&);
</span><span class="cx">     void setShowAllPlugins(bool);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (279216 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl       2021-06-24 08:31:48 UTC (rev 279216)
+++ trunk/Source/WebCore/testing/Internals.idl  2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -789,6 +789,7 @@
</span><span class="cx">     [Conditional=VIDEO] undefined setMediaControlsHidePlaybackRates(HTMLMediaElement element, boolean hidePlaybackRates);
</span><span class="cx"> 
</span><span class="cx">     DOMString userVisibleString(DOMURL url);
</span><ins>+    undefined setPageMediaVolume(float volume);
</ins><span class="cx"> 
</span><span class="cx">     undefined setShowAllPlugins(boolean showAll);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (279216 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-06-24 08:31:48 UTC (rev 279216)
+++ trunk/Tools/ChangeLog       2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2021-06-24  Enrique Ocaña González  <eocanha@igalia.com>
+
+        [GTK] media/muted-video-is-playing-audio.html is timing out
+        https://bugs.webkit.org/show_bug.cgi?id=208321
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Set the WebKitTestRunnerWPE application name on user-agent to ease the
+        detection of the WPE port from the layout tests using the isWPE()
+        function in platform-helper.js.
+
+        * WebKitTestRunner/wpe/TestControllerWPE.cpp:
+        (WTR::TestController::platformConfigureViewForTest): Set WebKitTestRunnerWPE application name on user-agent.
+
</ins><span class="cx"> 2021-06-23  Zan Dobersek  <zdobersek@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [WPE] WebKitGLibAPITestsCore should more explicitly link against library dependencies
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerwpeTestControllerWPEcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp (279216 => 279217)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp   2021-06-24 08:31:48 UTC (rev 279216)
+++ trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp      2021-06-24 09:31:16 UTC (rev 279217)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "TestController.h"
</span><span class="cx"> 
</span><ins>+#include "PlatformWebView.h"
</ins><span class="cx"> #include <glib.h>
</span><span class="cx"> #include <wtf/RunLoop.h>
</span><span class="cx"> #include <wtf/glib/GUniquePtr.h>
</span><span class="lines">@@ -130,6 +131,7 @@
</span><span class="cx"> 
</span><span class="cx"> void TestController::platformConfigureViewForTest(const TestInvocation&)
</span><span class="cx"> {
</span><ins>+    WKPageSetApplicationNameForUserAgent(mainWebView()->page(), WKStringCreateWithUTF8CString("WebKitTestRunnerWPE"));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool TestController::platformResetStateToConsistentValues(const TestOptions&)
</span></span></pre>
</div>
</div>

</body>
</html>