<!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>[213983] 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/213983">213983</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-03-15 09:38:10 -0700 (Wed, 15 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>run-webkit-tests is always creating mock libwebrtc tracks
https://bugs.webkit.org/show_bug.cgi?id=169658

Patch by Youenn Fablet &lt;youenn@apple.com&gt; on 2017-03-15
Reviewed by Alex Christensen.

Source/WebCore:

Tests: webrtc/peer-connection-audio-mute.html
       webrtc/video-mute.html

Creating real libwebrtc av tracks in case of RealTwoPeerConnections mock factory.

* testing/MockLibWebRTCPeerConnection.cpp:
(WebCore::MockLibWebRTCPeerConnectionFactory::CreateVideoTrack):
(WebCore::MockLibWebRTCPeerConnectionFactory::CreateAudioTrack):
* testing/MockLibWebRTCPeerConnection.h:

LayoutTests:

* TestExpectations:
* webrtc/audio-peer-connection-webaudio.html:
* webrtc/peer-connection-audio-mute-expected.txt: Added.
* webrtc/peer-connection-audio-mute.html: Added.
* webrtc/routines.js:
(analyseAudio):
* webrtc/video-expected.txt:
* webrtc/video-mute-expected.txt: Added.
* webrtc/video-mute.html: Added.
* webrtc/video.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsTestExpectationsorig">trunk/LayoutTests/TestExpectations.orig</a></li>
<li><a href="#trunkLayoutTestswebrtcaudiopeerconnectionwebaudiohtml">trunk/LayoutTests/webrtc/audio-peer-connection-webaudio.html</a></li>
<li><a href="#trunkLayoutTestswebrtcroutinesjs">trunk/LayoutTests/webrtc/routines.js</a></li>
<li><a href="#trunkLayoutTestswebrtcvideoexpectedtxt">trunk/LayoutTests/webrtc/video-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcvideohtml">trunk/LayoutTests/webrtc/video.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoretestingMockLibWebRTCPeerConnectioncpp">trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingMockLibWebRTCPeerConnectionh">trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswebrtcpeerconnectionaudiomuteexpectedtxt">trunk/LayoutTests/webrtc/peer-connection-audio-mute-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcpeerconnectionaudiomutehtml">trunk/LayoutTests/webrtc/peer-connection-audio-mute.html</a></li>
<li><a href="#trunkLayoutTestswebrtcvideomuteexpectedtxt">trunk/LayoutTests/webrtc/video-mute-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcvideomutehtml">trunk/LayoutTests/webrtc/video-mute.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/LayoutTests/ChangeLog        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2017-03-15  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        run-webkit-tests is always creating mock libwebrtc tracks
+        https://bugs.webkit.org/show_bug.cgi?id=169658
+
+        Reviewed by Alex Christensen.
+
+        * TestExpectations:
+        * webrtc/audio-peer-connection-webaudio.html:
+        * webrtc/peer-connection-audio-mute-expected.txt: Added.
+        * webrtc/peer-connection-audio-mute.html: Added.
+        * webrtc/routines.js:
+        (analyseAudio):
+        * webrtc/video-expected.txt:
+        * webrtc/video-mute-expected.txt: Added.
+        * webrtc/video-mute.html: Added.
+        * webrtc/video.html:
+
+2017-03-15  Youenn Fablet  &lt;youenn@apple.com&gt;
+
</ins><span class="cx">         Preventive clean-up: ensure RTCPeerConnection stays valid when calling postTask
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=169661
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/LayoutTests/TestExpectations        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -708,7 +708,7 @@
</span><span class="cx"> media/session [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> # WebRTC backend not enabled by default on Mac/iOS release bots.
</span><del>-# GTK enables some of this tests on their TestExpectations file.
</del><ins>+# GTK enables some of these tests on their TestExpectations file.
</ins><span class="cx"> [ Release ] webrtc [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> [ Debug ] webrtc/audio-peer-connection-webaudio.html [ Failure ]
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectationsorig"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations.orig (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations.orig        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/LayoutTests/TestExpectations.orig        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -733,6 +733,18 @@
</span><span class="cx"> imported/w3c/web-platform-tests/XMLHttpRequest/open-url-redirected-worker-origin.htm [ Skip ]
</span><span class="cx"> imported/w3c/web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.html [ Skip ]
</span><span class="cx"> imported/w3c/web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/NavigatorID.worker.html [ Skip ]
</span><ins>+imported/w3c/web-platform-tests/XMLHttpRequest/anonymous-mode-unsupported.htm [ Failure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/open-after-setrequestheader.htm [ Failure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/open-referer.htm [ Failure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/send-accept-language.htm [ Failure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-allow-empty-value.htm [ Failure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-allow-whitespace-in-value.htm [ Failure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-case-insensitive.htm [ Failure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-header-allowed.htm [ Failure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-header-forbidden.htm [ Failure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-open-setrequestheader.htm [ Failure ]
+imported/w3c/web-platform-tests/html/dom/interfaces.worker.html [ Failure ]
+imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-attributes-body-window.html [ Failure ]
</ins><span class="cx"> 
</span><span class="cx"> # Only iOS WK1 has testRunner.setPagePaused.
</span><span class="cx"> fast/dom/timer-fire-after-page-pause.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcaudiopeerconnectionwebaudiohtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/audio-peer-connection-webaudio.html (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/audio-peer-connection-webaudio.html        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/LayoutTests/webrtc/audio-peer-connection-webaudio.html        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -7,75 +7,28 @@
</span><span class="cx">     &lt;script src=&quot;../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src =&quot;routines.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script&gt;
</span><del>-    var test = async_test(() =&gt; {
</del><ins>+    promise_test((test) =&gt; {
</ins><span class="cx">         if (window.testRunner)
</span><span class="cx">             testRunner.setUserMediaPermission(true);
</span><span class="cx"> 
</span><del>-        var heardHum = false;
-        var heardBop = false;
-        var heardBip = false;
-
-        navigator.mediaDevices.getUserMedia({audio: true}).then((stream) =&gt; {
</del><ins>+       return navigator.mediaDevices.getUserMedia({audio: true}).then((stream) =&gt; {
</ins><span class="cx">             if (window.internals)
</span><span class="cx">                 internals.useMockRTCPeerConnectionFactory(&quot;TwoRealPeerConnections&quot;);
</span><del>-
-            createConnections((firstConnection) =&gt; {
-                firstConnection.addStream(stream);
-            }, (secondConnection) =&gt; {
-                secondConnection.onaddstream = (streamEvent) =&gt; {
-                    var context = new webkitAudioContext();
-                    var sourceNode = context.createMediaStreamSource(streamEvent.stream);
-                    var analyser = context.createAnalyser();
-                    var gain = context.createGain();
-
-                    analyser.fftSize = 2048;
-                    analyser.smoothingTimeConstant = 0;
-                    analyser.minDecibels = -100;
-                    analyser.maxDecibels = 0;
-                    gain.gain.value = 0;
-
-                    sourceNode.connect(analyser);
-                    analyser.connect(gain);
-                    gain.connect(context.destination);
-
-                    function analyse() {
-                        var freqDomain = new Uint8Array(analyser.frequencyBinCount);
-                        analyser.getByteFrequencyData(freqDomain);
-
-                        var hasFrequency = expectedFrequency =&gt; {
-                            var bin = Math.floor(expectedFrequency * analyser.fftSize / context.sampleRate);
-                            return bin &lt; freqDomain.length &amp;&amp; freqDomain[bin] &gt;= 150;
-                        };
-
-                        if (!heardHum)
-                            heardHum = hasFrequency(150);
-
-                        if (!heardBip)
-                            heardBip = hasFrequency(1500);
-
-                        if (!heardBop)
-                            heardBop = hasFrequency(500);
-
-                        if (heardHum &amp;&amp; heardBip &amp;&amp; heardBop)
-                            done();
-                    };
-
-                    var done = test.step_func_done(() =&gt; {
-                        clearTimeout(timeout);
-                        clearInterval(interval);
-
-                        assert_true(heardHum, &quot;heard hum&quot;);
-                        assert_true(heardBip, &quot;heard bip&quot;);
-                        assert_true(heardBop, &quot;heard bop&quot;);
-                        test.done();
-                    });
-
-                    var timeout = setTimeout(done, 3000);
-                    var interval = setInterval(analyse, 1000 / 30);
-                    analyse();
-                }
</del><ins>+            return new Promise((resolve, reject) =&gt; {
+                createConnections((firstConnection) =&gt; {
+                    firstConnection.addStream(stream);
+                }, (secondConnection) =&gt; {
+                    secondConnection.onaddstream = (streamEvent) =&gt; { resolve(streamEvent.stream); };
+                });
+                setTimeout(() =&gt; reject(&quot;Test timed out&quot;), 5000);
+            }).then((stream) =&gt; {
+                return analyseAudio(stream, 1000);
+            }).then((results) =&gt; {
+                assert_true(results.heardHum, &quot;heard hum&quot;);
+                assert_true(results.heardBip, &quot;heard bip&quot;);
+                assert_true(results.heardBop, &quot;heard bop&quot;);
</ins><span class="cx">             });
</span><del>-        });
</del><ins>+         });
</ins><span class="cx">     }, &quot;Basic audio playback through a peer connection&quot;);
</span><span class="cx">     &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcpeerconnectionaudiomuteexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/peer-connection-audio-mute-expected.txt (0 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/peer-connection-audio-mute-expected.txt                                (rev 0)
+++ trunk/LayoutTests/webrtc/peer-connection-audio-mute-expected.txt        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+FAIL Muting and unmuting an audio track assert_true: heard hum expected true got false
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcpeerconnectionaudiomutehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/peer-connection-audio-mute.html (0 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/peer-connection-audio-mute.html                                (rev 0)
+++ trunk/LayoutTests/webrtc/peer-connection-audio-mute.html        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Testing local audio capture playback causes &quot;playing&quot; event to fire&lt;/title&gt;
+    &lt;script src=&quot;../resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script src =&quot;routines.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+    promise_test((test) =&gt; {
+        if (window.testRunner)
+            testRunner.setUserMediaPermission(true);
+
+        return navigator.mediaDevices.getUserMedia({audio: true}).then((stream) =&gt; {
+            if (window.internals)
+                internals.useMockRTCPeerConnectionFactory(&quot;TwoRealPeerConnections&quot;);
+
+            var stream;
+            return new Promise((resolve, reject) =&gt; {
+                createConnections((firstConnection) =&gt; {
+                    firstConnection.addStream(stream);
+                }, (secondConnection) =&gt; {
+                    secondConnection.onaddstream = (streamEvent) =&gt; {
+                        stream = streamEvent.stream;
+                        resolve();
+                    };
+                });
+            }).then(() =&gt; {
+                return waitFor(500);
+            }).then(() =&gt; {
+                return analyseAudio(stream, 500).then((results) =&gt; {
+                    assert_true(results.heardHum, &quot;heard hum&quot;);
+                    assert_true(results.heardBip, &quot;heard bip&quot;);
+                    assert_true(results.heardBop, &quot;heard bop&quot;);
+                });
+            }).then(() =&gt; {
+                stream.getAudioTracks().forEach((track) =&gt; {
+                    track.enabled = false;
+                });
+                return waitFor(500);
+            }).then(() =&gt; {
+                return analyseAudio(stream, 500).then((results) =&gt; {
+                    assert_false(results.heardHum, &quot;heard hum&quot;);
+                    assert_false(results.heardBip, &quot;heard bip&quot;);
+                    assert_false(results.heardBop, &quot;heard bop&quot;);
+                });
+            }).then(() =&gt; {
+                stream.getAudioTracks().forEach((track) =&gt; {
+                    track.enabled = true;
+                });
+                return waitFor(500);
+            }).then(() =&gt; {
+                return analyseAudio(stream, 500).then((results) =&gt; {
+                    assert_true(results.heardHum, &quot;heard hum&quot;);
+                    assert_true(results.heardBip, &quot;heard bip&quot;);
+                    assert_true(results.heardBop, &quot;heard bop&quot;);
+                });
+            });
+        });
+    }, &quot;Muting and unmuting an audio track&quot;);
+    &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcroutinesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/routines.js (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/routines.js        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/LayoutTests/webrtc/routines.js        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -71,3 +71,62 @@
</span><span class="cx"> {
</span><span class="cx">     assert_unreached();
</span><span class="cx"> }
</span><ins>+
+function analyseAudio(stream, duration)
+{
+    return new Promise((resolve, reject) =&gt; {
+        var context = new webkitAudioContext();
+        var sourceNode = context.createMediaStreamSource(stream);
+        var analyser = context.createAnalyser();
+        var gain = context.createGain();
+
+        var results = { heardHum: false, heardBip: false, heardBop: false };
+
+        analyser.fftSize = 2048;
+        analyser.smoothingTimeConstant = 0;
+        analyser.minDecibels = -100;
+        analyser.maxDecibels = 0;
+        gain.gain.value = 0;
+
+        sourceNode.connect(analyser);
+        analyser.connect(gain);
+        gain.connect(context.destination);
+
+       function analyse() {
+           var freqDomain = new Uint8Array(analyser.frequencyBinCount);
+           analyser.getByteFrequencyData(freqDomain);
+
+           var hasFrequency = expectedFrequency =&gt; {
+                var bin = Math.floor(expectedFrequency * analyser.fftSize / context.sampleRate);
+                return bin &lt; freqDomain.length &amp;&amp; freqDomain[bin] &gt;= 150;
+           };
+
+           if (!results.heardHum)
+                results.heardHum = hasFrequency(150);
+
+           if (!results.heardBip)
+               results.heardBip = hasFrequency(1500);
+
+           if (!results.heardBop)
+                results.heardBop = hasFrequency(500);
+
+            if (results.heardHum &amp;&amp; results.heardBip &amp;&amp; results.heardBop)
+                done();
+        };
+
+       function done() {
+            clearTimeout(timeout);
+            clearInterval(interval);
+            resolve(results);
+       }
+
+        var timeout = setTimeout(done, 3 * duration);
+        var interval = setInterval(analyse, duration / 30);
+        analyse();
+    });
+}
+
+function waitFor(duration)
+{
+    return new Promise((resolve) =&gt; setTimeout(resolve, duration));
+}
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcvideoexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/video-expected.txt (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-expected.txt        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/LayoutTests/webrtc/video-expected.txt        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-FAIL Basic video exchange assert_true: expected true got false
</del><ins>+PASS Basic video exchange 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcvideomuteexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/video-mute-expected.txt (0 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-mute-expected.txt                                (rev 0)
+++ trunk/LayoutTests/webrtc/video-mute-expected.txt        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+
+PASS Video muted/unmuted track 
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcvideomutehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/video-mute.html (0 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-mute.html                                (rev 0)
+++ trunk/LayoutTests/webrtc/video-mute.html        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;meta charset=&quot;utf-8&quot;&gt;
+        &lt;title&gt;Testing basic video exchange from offerer to receiver&lt;/title&gt;
+        &lt;script src=&quot;../resources/testharness.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;video id=&quot;video&quot; autoplay=&quot;&quot;&gt;&lt;/video&gt;
+        &lt;canvas id=&quot;canvas&quot; width=&quot;640&quot; height=&quot;480&quot;&gt;&lt;/canvas&gt;
+        &lt;script src =&quot;routines.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+video = document.getElementById(&quot;video&quot;);
+canvas = document.getElementById(&quot;canvas&quot;);
+// FIXME: We should use tracks
+
+function isVideoBlack()
+{
+    canvas.width = video.videoWidth;
+    canvas.height = video.videoHeight;
+    canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
+
+    imageData = canvas.getContext('2d').getImageData(10, 325, 250, 1);
+    data = imageData.data;
+    for (var cptr = 0; cptr &lt; canvas.width * canvas.height; ++cptr) {
+        if (data[4 * cptr] || data[4 * cptr + 1] || data[4 * cptr + 2])
+            return false;
+    }
+    return true;
+}
+
+var track;
+promise_test((test) =&gt; {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) =&gt; {
+        return new Promise((resolve, reject) =&gt; {
+            if (window.internals)
+                internals.useMockRTCPeerConnectionFactory(&quot;TwoRealPeerConnections&quot;);
+
+            createConnections((firstConnection) =&gt; {
+                firstConnection.addStream(stream);
+            }, (secondConnection) =&gt; {
+                secondConnection.onaddstream = (streamEvent) =&gt; { resolve(streamEvent.stream); };
+            });
+            setTimeout(() =&gt; reject(&quot;Test timed out&quot;), 5000);
+        });
+    }).then((stream) =&gt; {
+        video.srcObject = stream;
+        track = stream.getVideoTracks()[0];
+        return video.play();
+    }).then(() =&gt; {
+         assert_false(isVideoBlack());
+    }).then(() =&gt; {
+        track.enabled = false;
+        return waitFor(500);
+    }).then(() =&gt; {
+        assert_true(isVideoBlack());
+        track.enabled = true;
+        return waitFor(500);
+    }).then(() =&gt; {
+        assert_false(isVideoBlack());
+    });
+}, &quot;Video muted/unmuted track&quot;);
+        &lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcvideohtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/video.html (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video.html        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/LayoutTests/webrtc/video.html        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -11,12 +11,6 @@
</span><span class="cx">         &lt;canvas id=&quot;canvas&quot; width=&quot;640&quot; height=&quot;480&quot;&gt;&lt;/canvas&gt;
</span><span class="cx">         &lt;script src =&quot;routines.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">         &lt;script&gt;
</span><del>-if (window.internals)
-    internals.useMockRTCPeerConnectionFactory(&quot;TwoRealPeerConnections&quot;);
-
-if (window.testRunner)
-    testRunner.setUserMediaPermission(true);
-
</del><span class="cx"> video = document.getElementById(&quot;video&quot;);
</span><span class="cx"> canvas = document.getElementById(&quot;canvas&quot;);
</span><span class="cx"> // FIXME: We should use tracks
</span><span class="lines">@@ -23,56 +17,50 @@
</span><span class="cx"> 
</span><span class="cx"> function testImage()
</span><span class="cx"> {
</span><del>-    try {
-        canvas.width = video.videoWidth;
-        canvas.height = video.videoHeight;
-        canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
</del><ins>+    canvas.width = video.videoWidth;
+    canvas.height = video.videoHeight;
+    canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
</ins><span class="cx"> 
</span><del>-        imageData = canvas.getContext('2d').getImageData(10, 325, 250, 1);
-        data = imageData.data;
</del><ins>+    imageData = canvas.getContext('2d').getImageData(10, 325, 250, 1);
+    data = imageData.data;
</ins><span class="cx"> 
</span><del>-        var index = 20;
-        assert_true(data[index] &lt; 100);
-        assert_true(data[index + 1] &lt; 100);
-        assert_true(data[index + 2] &lt; 100);
</del><ins>+    var index = 20;
+    assert_true(data[index] &lt; 100);
+    assert_true(data[index + 1] &lt; 100);
+    assert_true(data[index + 2] &lt; 100);
</ins><span class="cx"> 
</span><del>-        index = 80;
-        assert_true(data[index] &gt; 200);
-        assert_true(data[index + 1] &gt; 200);
-        assert_true(data[index + 2] &gt; 200);
</del><ins>+    index = 80;
+    assert_true(data[index] &gt; 200);
+    assert_true(data[index + 1] &gt; 200);
+    assert_true(data[index + 2] &gt; 200);
</ins><span class="cx"> 
</span><del>-        index += 80;
-        assert_true(data[index] &gt; 200);
-        assert_true(data[index + 1] &gt; 200);
-        assert_true(data[index + 2] &lt; 100);
-
-        finishTest();
-    } catch(e) {
-        errorTest(e);
-    }
</del><ins>+    index += 80;
+    assert_true(data[index] &gt; 200);
+    assert_true(data[index + 1] &gt; 200);
+    assert_true(data[index + 2] &lt; 100);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-function testStream(stream)
-{
-    video.srcObject = stream;
-    // Video may play with black frames
-    video.onplay = setTimeout(() =&gt; {
-        testImage();
-    }, 1000);
-}
</del><ins>+promise_test((test) =&gt; {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
</ins><span class="cx"> 
</span><del>-var finishTest, errorTest;
-promise_test((test) =&gt; {
</del><span class="cx">     return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) =&gt; {
</span><span class="cx">         return new Promise((resolve, reject) =&gt; {
</span><del>-            finishTest = resolve;
-            errorTest = reject;
</del><ins>+            if (window.internals)
+                internals.useMockRTCPeerConnectionFactory(&quot;TwoRealPeerConnections&quot;);
+
</ins><span class="cx">             createConnections((firstConnection) =&gt; {
</span><span class="cx">                 firstConnection.addStream(stream);
</span><span class="cx">             }, (secondConnection) =&gt; {
</span><del>-                secondConnection.onaddstream = (streamEvent) =&gt; { testStream(streamEvent.stream); };
</del><ins>+                secondConnection.onaddstream = (streamEvent) =&gt; { resolve(streamEvent.stream); };
</ins><span class="cx">             });
</span><ins>+            setTimeout(() =&gt; reject(&quot;Test timed out&quot;), 5000);
</ins><span class="cx">         });
</span><ins>+    }).then((stream) =&gt; {
+        video.srcObject = stream;
+        return video.play();
+    }).then(() =&gt; {
+        testImage();
</ins><span class="cx">     });
</span><span class="cx"> }, &quot;Basic video exchange&quot;);
</span><span class="cx">         &lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/Source/WebCore/ChangeLog        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2017-03-15  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        run-webkit-tests is always creating mock libwebrtc tracks
+        https://bugs.webkit.org/show_bug.cgi?id=169658
+
+        Reviewed by Alex Christensen.
+
+        Tests: webrtc/peer-connection-audio-mute.html
+               webrtc/video-mute.html
+
+        Creating real libwebrtc av tracks in case of RealTwoPeerConnections mock factory.
+
+        * testing/MockLibWebRTCPeerConnection.cpp:
+        (WebCore::MockLibWebRTCPeerConnectionFactory::CreateVideoTrack):
+        (WebCore::MockLibWebRTCPeerConnectionFactory::CreateAudioTrack):
+        * testing/MockLibWebRTCPeerConnection.h:
+
+2017-03-15  Youenn Fablet  &lt;youenn@apple.com&gt;
+
</ins><span class="cx">         Preventive clean-up: ensure RTCPeerConnection stays valid when calling postTask
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=169661
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockLibWebRTCPeerConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -189,6 +189,20 @@
</span><span class="cx">     return new rtc::RefCountedObject&lt;MockLibWebRTCPeerConnection&gt;(*observer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+rtc::scoped_refptr&lt;webrtc::VideoTrackInterface&gt; MockLibWebRTCPeerConnectionFactory::CreateVideoTrack(const std::string&amp; id, webrtc::VideoTrackSourceInterface* source)
+{
+    if (m_testCase == &quot;TwoRealPeerConnections&quot;)
+        return realPeerConnectionFactory()-&gt;CreateVideoTrack(id, source);
+    return new rtc::RefCountedObject&lt;MockLibWebRTCVideoTrack&gt;(id, source);
+}
+
+rtc::scoped_refptr&lt;webrtc::AudioTrackInterface&gt; MockLibWebRTCPeerConnectionFactory::CreateAudioTrack(const std::string&amp; id, webrtc::AudioSourceInterface* source)
+{
+    if (m_testCase == &quot;TwoRealPeerConnections&quot;)
+        return realPeerConnectionFactory()-&gt;CreateAudioTrack(id, source);
+    return new rtc::RefCountedObject&lt;MockLibWebRTCAudioTrack&gt;(id, source);
+}
+
</ins><span class="cx"> rtc::scoped_refptr&lt;webrtc::MediaStreamInterface&gt; MockLibWebRTCPeerConnectionFactory::CreateLocalMediaStream(const std::string&amp; label)
</span><span class="cx"> {
</span><span class="cx">     return new rtc::RefCountedObject&lt;webrtc::MediaStream&gt;(label);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockLibWebRTCPeerConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.h (213982 => 213983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.h        2017-03-15 16:35:18 UTC (rev 213982)
+++ trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.h        2017-03-15 16:38:10 UTC (rev 213983)
</span><span class="lines">@@ -244,8 +244,9 @@
</span><span class="cx">     rtc::scoped_refptr&lt;webrtc::VideoTrackSourceInterface&gt; CreateVideoSource(cricket::VideoCapturer*) final { return nullptr; }
</span><span class="cx">     rtc::scoped_refptr&lt;webrtc::VideoTrackSourceInterface&gt; CreateVideoSource(cricket::VideoCapturer*, const webrtc::MediaConstraintsInterface*) final { return nullptr; }
</span><span class="cx"> 
</span><del>-    rtc::scoped_refptr&lt;webrtc::VideoTrackInterface&gt; CreateVideoTrack(const std::string&amp; id, webrtc::VideoTrackSourceInterface* source) final { return new rtc::RefCountedObject&lt;MockLibWebRTCVideoTrack&gt;(id, source); }
-    rtc::scoped_refptr&lt;webrtc::AudioTrackInterface&gt; CreateAudioTrack(const std::string&amp; id, webrtc::AudioSourceInterface* source) final { return new rtc::RefCountedObject&lt;MockLibWebRTCAudioTrack&gt;(id, source); }
</del><ins>+    rtc::scoped_refptr&lt;webrtc::VideoTrackInterface&gt; CreateVideoTrack(const std::string&amp;, webrtc::VideoTrackSourceInterface*) final;
+    rtc::scoped_refptr&lt;webrtc::AudioTrackInterface&gt; CreateAudioTrack(const std::string&amp;, webrtc::AudioSourceInterface*) final;
+
</ins><span class="cx">     bool StartAecDump(rtc::PlatformFile, int64_t) final { return false; }
</span><span class="cx">     void StopAecDump() final { }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>