<!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>[218408] trunk/LayoutTests</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/218408">218408</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-06-16 13:24:09 -0700 (Fri, 16 Jun 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make some WebRTC tests easier to debug when failing
https://bugs.webkit.org/show_bug.cgi?id=173480

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-16
Reviewed by Eric Carlson.

* webrtc/captureCanvas-webrtc-expected.txt:
* webrtc/captureCanvas-webrtc.html: Splitting test in smaller tests.
* webrtc/datachannel/basic-expected.txt:
* webrtc/datachannel/basic-tcp-expected.txt: Added.
* webrtc/datachannel/basic-tcp.html: Test from basic.html
* webrtc/datachannel/basic.html: Moving TCP specifict test and other creation tests to their own files.
* webrtc/datachannel/bufferedAmountLowThreshold.html: Removing console log message in case of unhandled promise.
* webrtc/datachannel/creation-expected.txt:
* webrtc/datachannel/creation.html: Test from basic.html
* webrtc/datachannel/filter-ice-candidate-expected.txt:
* webrtc/datachannel/filter-ice-candidate.html: Exchanging the tests.
* webrtc/video-stats.html: Improving test that timestamp is milliseconds and not microseconds.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestswebrtccaptureCanvaswebrtcexpectedtxt">trunk/LayoutTests/webrtc/captureCanvas-webrtc-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtccaptureCanvaswebrtchtml">trunk/LayoutTests/webrtc/captureCanvas-webrtc.html</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelbasicexpectedtxt">trunk/LayoutTests/webrtc/datachannel/basic-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelbasichtml">trunk/LayoutTests/webrtc/datachannel/basic.html</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelbufferedAmountLowThresholdhtml">trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold.html</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelfiltericecandidateexpectedtxt">trunk/LayoutTests/webrtc/datachannel/filter-ice-candidate-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelfiltericecandidatehtml">trunk/LayoutTests/webrtc/datachannel/filter-ice-candidate.html</a></li>
<li><a href="#trunkLayoutTestswebrtcvideostatshtml">trunk/LayoutTests/webrtc/video-stats.html</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswebrtcdatachannelbasictcpexpectedtxt">trunk/LayoutTests/webrtc/datachannel/basic-tcp-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelbasictcphtml">trunk/LayoutTests/webrtc/datachannel/basic-tcp.html</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelcreationexpectedtxt">trunk/LayoutTests/webrtc/datachannel/creation-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachannelcreationhtml">trunk/LayoutTests/webrtc/datachannel/creation.html</a></li>
<li><a href="#trunkLayoutTestswebrtcdatachanneltesthtml">trunk/LayoutTests/webrtc/datachannel/test.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (218407 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2017-06-16 20:22:36 UTC (rev 218407)
+++ trunk/LayoutTests/ChangeLog 2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2017-06-16  Youenn Fablet  <youenn@apple.com>
+
+        Make some WebRTC tests easier to debug when failing
+        https://bugs.webkit.org/show_bug.cgi?id=173480
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/captureCanvas-webrtc-expected.txt:
+        * webrtc/captureCanvas-webrtc.html: Splitting test in smaller tests.
+        * webrtc/datachannel/basic-expected.txt:
+        * webrtc/datachannel/basic-tcp-expected.txt: Added.
+        * webrtc/datachannel/basic-tcp.html: Test from basic.html
+        * webrtc/datachannel/basic.html: Moving TCP specifict test and other creation tests to their own files.
+        * webrtc/datachannel/bufferedAmountLowThreshold.html: Removing console log message in case of unhandled promise.
+        * webrtc/datachannel/creation-expected.txt:
+        * webrtc/datachannel/creation.html: Test from basic.html
+        * webrtc/datachannel/filter-ice-candidate-expected.txt:
+        * webrtc/datachannel/filter-ice-candidate.html: Exchanging the tests.
+        * webrtc/video-stats.html: Improving test that timestamp is milliseconds and not microseconds.
+
</ins><span class="cx"> 2017-06-16  Antoine Quint  <graouts@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION: AirPlay placard is not shown when in fullscreen
</span></span></pre></div>
<a id="trunkLayoutTestswebrtccaptureCanvaswebrtcexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/captureCanvas-webrtc-expected.txt (218407 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/captureCanvas-webrtc-expected.txt       2017-06-16 20:22:36 UTC (rev 218407)
+++ trunk/LayoutTests/webrtc/captureCanvas-webrtc-expected.txt  2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -1,4 +1,7 @@
</span><span class="cx">    
</span><span class="cx"> 
</span><del>-PASS captureStream with webrtc 
</del><ins>+PASS Setting up the connection 
+PASS Checking canvas is green 
+PASS Checking canvas is red 
+PASS Checking canvas is green again 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebrtccaptureCanvaswebrtchtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/captureCanvas-webrtc.html (218407 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/captureCanvas-webrtc.html       2017-06-16 20:22:36 UTC (rev 218407)
+++ trunk/LayoutTests/webrtc/captureCanvas-webrtc.html  2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -41,25 +41,32 @@
</span><span class="cx">     }).then((stream) => {
</span><span class="cx">         video.srcObject = stream;
</span><span class="cx">         return video.play();
</span><del>-    }).then(() => {
-         return waitFor(100);
-    }).then(() => {
</del><ins>+    });
+}, "Setting up the connection");
+
+promise_test((test) => {
+    return waitFor(100).then(() => {
</ins><span class="cx">         canvas2.getContext("2d").drawImage(video, 0 ,0);
</span><span class="cx">         assert_array_equals(canvas2.getContext("2d").getImageData(20 ,20, 60, 60), canvas1.getContext("2d").getImageData(20, 20, 60, 60));
</span><del>-    }).then(() => {
-        color = "red";
-         return waitFor(300);
-    }).then(() => {
</del><ins>+    });
+}, "Checking canvas is green");
+
+promise_test((test) => {
+    color = "red";
+    return waitFor(300).then(() => {
</ins><span class="cx">         canvas2.getContext("2d").drawImage(video, 0 ,0);
</span><span class="cx">         assert_array_equals(canvas2.getContext("2d").getImageData(20 ,20, 60, 60), canvas1.getContext("2d").getImageData(20, 20, 60, 60));
</span><del>-    }).then(() => {
-        color = "green";
-        return waitFor(300);
-    }).then(() => {
</del><ins>+    });
+}, "Checking canvas is red");
+
+
+promise_test((test) => {
+    color = "green";
+    return waitFor(300).then(() => {
</ins><span class="cx">         canvas2.getContext("2d").drawImage(video, 0 ,0);
</span><span class="cx">         assert_array_equals(canvas2.getContext("2d").getImageData(20 ,20, 60, 60), canvas1.getContext("2d").getImageData(20, 20, 60, 60));
</span><span class="cx">     });
</span><del>-}, "captureStream with webrtc");
</del><ins>+}, "Checking canvas is green again");
</ins><span class="cx">         </script>
</span><span class="cx">     </head>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelbasicexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/datachannel/basic-expected.txt (218407 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/basic-expected.txt  2017-06-16 20:22:36 UTC (rev 218407)
+++ trunk/LayoutTests/webrtc/datachannel/basic-expected.txt     2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -2,16 +2,5 @@
</span><span class="cx"> PASS Basic data channel exchange from offerer to receiver 
</span><span class="cx"> PASS Basic data channel exchange from receiver to offerer 
</span><span class="cx"> PASS Basic data channel exchange from offerer to receiver using UDP only 
</span><del>-PASS Basic data channel exchange from offerer to receiver using TCP only 
</del><span class="cx"> PASS Basic data channel exchange from offerer to receiver 
</span><del>-PASS Creating data channel with very long label 
-PASS Creating data channel after closing the connection 
-PASS Wrong data channel init: long protocol 
-PASS Wrong data channel init: long id 
-PASS Wrong data channel init: maxPacketLifeTime and maxRetransmits 
-PASS Right data channel init: ordered init 
-PASS Right data channel init: unordered init 
-PASS Right data channel init: default ordered init with id 
-PASS Right data channel init: no init 
-PASS Right data channel init: null 
</del><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelbasictcpexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/datachannel/basic-tcp-expected.txt (0 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/basic-tcp-expected.txt                              (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/basic-tcp-expected.txt 2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+PASS Basic data channel exchange from offerer to receiver using TCP only 
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelbasictcphtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/datachannel/basic-tcp.html (0 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/basic-tcp.html                              (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/basic-tcp.html 2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Testing basic data channel from offerer to receiver</title>
+    <script src="../../resources/testharness.js"></script>
+    <script src="../../resources/testharnessreport.js"></script>
+  </head>
+  <body>
+    <script src ="../routines.js"></script>
+    <script>
+var localChannel;
+var remoteChannel;
+
+function closeDataChannels() {
+    localChannel.close();
+    remoteChannel.close();
+    closeConnections();
+}
+
+function receiveMessages(event) {
+try {
+    if (++counter === 1)
+        assert_equals(event.data, "one");
+    else if (counter === 2)
+        assert_equals(event.data, "two");
+    else if (counter === 3)
+        assert_equals(event.data, "three");
+    else if (counter === 4) {
+        assert_equals(event.data, "four");
+        closeDataChannels();
+        finishTest();
+    } else
+        assert_unreached();
+} catch(e) {
+    console.log(e);
+}
+}
+
+function sendMessages(channel)
+{
+    channel.send("one");
+    channel.send("two");
+    channel.send("three");
+    channel.send("four");
+}
+
+var finishTest;
+promise_test((test) => {
+    counter = 0;
+    return new Promise((resolve, reject) => {
+        if (window.internals) {
+            internals.setEnumeratingAllNetworkInterfacesEnabled(true);
+        }
+
+        finishTest = resolve;
+        createConnections((localConnection) => {
+            localChannel = localConnection.createDataChannel('sendDataChannel');
+            localChannel.onopen = () => { sendMessages(localChannel) };
+        }, (remoteConnection) => {
+            remoteConnection.ondatachannel = (event) => {
+                remoteChannel = event.channel;
+                remoteChannel.onmessage = receiveMessages;
+            };
+        }, { filterOutICECandidate: (candidate) => { return candidate && candidate.candidate.toLowerCase().indexOf("tcp") == -1; } });
+        setTimeout(() => { reject("Test timed out"); }, 5000);
+    });
+}, "Basic data channel exchange from offerer to receiver using TCP only");
+    </script>
+  </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelbasichtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/datachannel/basic.html (218407 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/basic.html  2017-06-16 20:22:36 UTC (rev 218407)
+++ trunk/LayoutTests/webrtc/datachannel/basic.html     2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -19,6 +19,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function receiveMessages(event) {
</span><ins>+try {
</ins><span class="cx">     if (++counter === 1)
</span><span class="cx">         assert_equals(event.data, "one");
</span><span class="cx">     else if (counter === 2)
</span><span class="lines">@@ -31,7 +32,10 @@
</span><span class="cx">         finishTest();
</span><span class="cx">     } else
</span><span class="cx">         assert_unreached();
</span><ins>+} catch(e) {
+    console.log(e);
</ins><span class="cx"> }
</span><ins>+}
</ins><span class="cx"> 
</span><span class="cx"> function sendMessages(channel)
</span><span class="cx"> {
</span><span class="lines">@@ -55,6 +59,7 @@
</span><span class="cx">                 remoteChannel.onmessage = receiveMessages;
</span><span class="cx">             };
</span><span class="cx">         });
</span><ins>+        setTimeout(() => { reject("Test timed out"); }, 5000);
</ins><span class="cx">     });
</span><span class="cx"> }, "Basic data channel exchange from offerer to receiver");
</span><span class="cx"> 
</span><span class="lines">@@ -71,9 +76,11 @@
</span><span class="cx">                 remoteChannel.onopen = () => { sendMessages(remoteChannel) };
</span><span class="cx">             };
</span><span class="cx">         });
</span><ins>+        setTimeout(() => { reject("Test timed out"); }, 5000);
</ins><span class="cx">     });
</span><span class="cx"> }, "Basic data channel exchange from receiver to offerer");
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> promise_test((test) => {
</span><span class="cx">     counter = 0;
</span><span class="cx">     return new Promise((resolve, reject) => {
</span><span class="lines">@@ -87,6 +94,7 @@
</span><span class="cx">                 remoteChannel.onmessage = receiveMessages;
</span><span class="cx">             };
</span><span class="cx">         }, { filterOutICECandidate: (candidate) => { return candidate && candidate.candidate.toLowerCase().indexOf("udp") == -1; } });
</span><ins>+        setTimeout(() => { reject("Test timed out"); }, 5000);
</ins><span class="cx">     });
</span><span class="cx"> }, "Basic data channel exchange from offerer to receiver using UDP only");
</span><span class="cx"> 
</span><span class="lines">@@ -93,26 +101,6 @@
</span><span class="cx"> promise_test((test) => {
</span><span class="cx">     counter = 0;
</span><span class="cx">     return new Promise((resolve, reject) => {
</span><del>-        if (window.internals) {
-            internals.setEnumeratingAllNetworkInterfacesEnabled(true);
-        }
-
-        finishTest = resolve;
-        createConnections((localConnection) => {
-            localChannel = localConnection.createDataChannel('sendDataChannel');
-            localChannel.onopen = () => { sendMessages(localChannel) };
-        }, (remoteConnection) => {
-            remoteConnection.ondatachannel = (event) => {
-                remoteChannel = event.channel;
-                remoteChannel.onmessage = receiveMessages;
-            };
-        }, { filterOutICECandidate: (candidate) => { return candidate && candidate.candidate.toLowerCase().indexOf("tcp") == -1; } });
-    });
-}, "Basic data channel exchange from offerer to receiver using TCP only");
-
-promise_test((test) => {
-    counter = 0;
-    return new Promise((resolve, reject) => {
</del><span class="cx">         var checkDataChannelOptions = (channel, init) => {
</span><span class="cx">             assert_equals(channel.ordered, init.ordered, "ordered");
</span><span class="cx">             assert_equals(channel.maxPacketLifeTime, init.maxPacketLifeTime, "maxPacketLifeTime");
</span><span class="lines">@@ -134,72 +122,10 @@
</span><span class="cx">                 remoteChannel.onmessage = receiveMessages;
</span><span class="cx">             };
</span><span class="cx">         });
</span><ins>+        setTimeout(() => { reject("Test timed out"); }, 5000);
</ins><span class="cx">     });
</span><span class="cx"> }, "Basic data channel exchange from offerer to receiver");
</span><span class="cx"> 
</span><del>-var longString = "abcdefgh";
-for (var cptr = 0; cptr < 16; ++cptr)
-    longString += longString;
-
-test(() => {
-    var pc = new RTCPeerConnection();
-    assert_throws(new TypeError, () => { pc.createDataChannel(longString); });
-}, "Creating data channel with very long label");
-
-test(() => {
-    var pc = new RTCPeerConnection();
-    pc.close();
-    assert_throws("InvalidStateError", () => { pc.createDataChannel('sendDataChannel'); });
-}, "Creating data channel after closing the connection");
-
-function testWrongDataChannelInit(init, title)
-{
-    return test(() => {
-        var pc = new RTCPeerConnection();
-        assert_throws(new TypeError, () => { pc.createDataChannel('sendDataChannel', init); });
-    }, "Wrong data channel init: " + title);
-}
-
-function testRightDataChannelInit(init, title)
-{
-    return test(() => {
-        var pc = new RTCPeerConnection();
-        channel = pc.createDataChannel('sendDataChannel', init);
-
-        if (!init)
-            init = { };
-        if (init.ordered === undefined)
-            init.ordered = true;
-        if (init.maxPacketLifeTime === undefined)
-            init.maxPacketLifeTime = null;
-        if (init.maxRetransmits === undefined)
-            init.maxRetransmits = null;
-        if (init.protocol === undefined)
-            init.protocol = "";
-        if (init.negotiated === undefined)
-            init.negotiated = false;
-        if (init.id === undefined)
-            init.id = null;
-
-        assert_equals(channel.ordered, init.ordered, "ordered");
-        assert_equals(channel.maxPacketLifeTime, init.maxPacketLifeTime, "maxPacketLifeTime");
-        assert_equals(channel.maxRetransmitTime, init.maxRetransmitTime, "maxRetransmitTime");
-        assert_equals(channel.maxRetransmits, init.maxRetransmits, "maxRetransmits");
-        assert_equals(channel.protocol, init.protocol, "protocol");
-        assert_equals(channel.negotiated, init.negotiated, "negotiated");
-        assert_equals(channel.id, init.id, "id");
-     }, "Right data channel init: " + title);
-}
-
-testWrongDataChannelInit({negotiated: false, protocol: longString}, "long protocol");
-testWrongDataChannelInit({id: 65535}, "long id");
-testWrongDataChannelInit({maxPacketLifeTime: 1, maxRetransmits: 1}, "maxPacketLifeTime and maxRetransmits");
-
-testRightDataChannelInit({ordered: true, maxRetransmit: 11, protocol: "whatever", negotiated: false, id: 1 }, "ordered init");
-testRightDataChannelInit({ordered: false, maxPacketLifeTime: 10, protocol: "whatever", negotiated: false, id: 2 }, "unordered init");
-testRightDataChannelInit({protocol: "whatever", negotiated: false, id: 123 }, "default ordered init with id");
-testRightDataChannelInit(undefined, "no init");
-testRightDataChannelInit(null, "null");
</del><span class="cx">     </script>
</span><span class="cx">   </body>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelbufferedAmountLowThresholdhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold.html (218407 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold.html     2017-06-16 20:22:36 UTC (rev 218407)
+++ trunk/LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold.html        2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -9,6 +9,10 @@
</span><span class="cx">   <body>
</span><span class="cx">     <script src ="../routines.js"></script>
</span><span class="cx">     <script>
</span><ins>+window.addEventListener("unhandledrejection", event => {
+    event.preventDefault();
+});
+
</ins><span class="cx"> var localChannel;
</span><span class="cx"> var remoteChannel;
</span><span class="cx"> 
</span><span class="lines">@@ -113,8 +117,6 @@
</span><span class="cx">             };
</span><span class="cx">         });
</span><span class="cx">         setTimeout(resolve, 50);
</span><del>-    }).then (() => {
-        closeDataChannels();
</del><span class="cx">     });
</span><span class="cx"> }, "Medium buffer threshold not reached");
</span><span class="cx">     </script>
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelcreationexpectedtxtfromrev218407trunkLayoutTestswebrtcdatachannelbasicexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/webrtc/datachannel/creation-expected.txt (from rev 218407, trunk/LayoutTests/webrtc/datachannel/basic-expected.txt) (0 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/creation-expected.txt                               (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/creation-expected.txt  2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+
+PASS Creating data channel with very long label 
+PASS Creating data channel after closing the connection 
+PASS Wrong data channel init: long protocol 
+PASS Wrong data channel init: long id 
+PASS Wrong data channel init: maxPacketLifeTime and maxRetransmits 
+PASS Right data channel init: ordered init 
+PASS Right data channel init: unordered init 
+PASS Right data channel init: default ordered init with id 
+PASS Right data channel init: no init 
+PASS Right data channel init: null 
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelcreationhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/datachannel/creation.html (0 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/creation.html                               (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/creation.html  2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Testing basic data channel creation</title>
+    <script src="../../resources/testharness.js"></script>
+    <script src="../../resources/testharnessreport.js"></script>
+  </head>
+  <body>
+    <script>
+var longString = "abcdefgh";
+for (var cptr = 0; cptr < 16; ++cptr)
+    longString += longString;
+
+test(() => {
+    var pc = new RTCPeerConnection();
+    assert_throws(new TypeError, () => { pc.createDataChannel(longString); });
+}, "Creating data channel with very long label");
+
+test(() => {
+    var pc = new RTCPeerConnection();
+    pc.close();
+    assert_throws("InvalidStateError", () => { pc.createDataChannel('sendDataChannel'); });
+}, "Creating data channel after closing the connection");
+
+function testWrongDataChannelInit(init, title)
+{
+    return test(() => {
+        var pc = new RTCPeerConnection();
+        assert_throws(new TypeError, () => { pc.createDataChannel('sendDataChannel', init); });
+    }, "Wrong data channel init: " + title);
+}
+
+function testRightDataChannelInit(init, title)
+{
+    return test(() => {
+        var pc = new RTCPeerConnection();
+        channel = pc.createDataChannel('sendDataChannel', init);
+
+        if (!init)
+            init = { };
+        if (init.ordered === undefined)
+            init.ordered = true;
+        if (init.maxPacketLifeTime === undefined)
+            init.maxPacketLifeTime = null;
+        if (init.maxRetransmits === undefined)
+            init.maxRetransmits = null;
+        if (init.protocol === undefined)
+            init.protocol = "";
+        if (init.negotiated === undefined)
+            init.negotiated = false;
+        if (init.id === undefined)
+            init.id = null;
+
+        assert_equals(channel.ordered, init.ordered, "ordered");
+        assert_equals(channel.maxPacketLifeTime, init.maxPacketLifeTime, "maxPacketLifeTime");
+        assert_equals(channel.maxRetransmitTime, init.maxRetransmitTime, "maxRetransmitTime");
+        assert_equals(channel.maxRetransmits, init.maxRetransmits, "maxRetransmits");
+        assert_equals(channel.protocol, init.protocol, "protocol");
+        assert_equals(channel.negotiated, init.negotiated, "negotiated");
+        assert_equals(channel.id, init.id, "id");
+     }, "Right data channel init: " + title);
+}
+
+testWrongDataChannelInit({negotiated: false, protocol: longString}, "long protocol");
+testWrongDataChannelInit({id: 65535}, "long id");
+testWrongDataChannelInit({maxPacketLifeTime: 1, maxRetransmits: 1}, "maxPacketLifeTime and maxRetransmits");
+
+testRightDataChannelInit({ordered: true, maxRetransmit: 11, protocol: "whatever", negotiated: false, id: 1 }, "ordered init");
+testRightDataChannelInit({ordered: false, maxPacketLifeTime: 10, protocol: "whatever", negotiated: false, id: 2 }, "unordered init");
+testRightDataChannelInit({protocol: "whatever", negotiated: false, id: 123 }, "default ordered init with id");
+testRightDataChannelInit(undefined, "no init");
+testRightDataChannelInit(null, "null");
+    </script>
+  </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelfiltericecandidateexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/datachannel/filter-ice-candidate-expected.txt (218407 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/filter-ice-candidate-expected.txt   2017-06-16 20:22:36 UTC (rev 218407)
+++ trunk/LayoutTests/webrtc/datachannel/filter-ice-candidate-expected.txt      2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><span class="cx"> 
</span><ins>+PASS Gathering ICE candidates from a data channel peer connection with ICE candidate filtering on 
</ins><span class="cx"> PASS Gathering ICE candidates from a data channel peer connection with ICE candidate filtering off 
</span><del>-PASS Gathering ICE candidates from a data channel peer connection with ICE candidate filtering on 
</del><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachannelfiltericecandidatehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/datachannel/filter-ice-candidate.html (218407 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/filter-ice-candidate.html   2017-06-16 20:22:36 UTC (rev 218407)
+++ trunk/LayoutTests/webrtc/datachannel/filter-ice-candidate.html      2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -9,10 +9,12 @@
</span><span class="cx">   <body>
</span><span class="cx">     <script>
</span><span class="cx"> promise_test((test) => {
</span><del>-    if (window.internals)
-        internals.setICECandidateFiltering(false);
</del><ins>+    return new Promise((resolve, reject) => {
+        setTimeout(() => { reject("Test timed out"); }, 5000);
</ins><span class="cx"> 
</span><del>-    return new Promise((resolve, reject) => {
</del><ins>+        if (window.internals)
+            internals.setICECandidateFiltering(true);
+
</ins><span class="cx">         var counter = 0;
</span><span class="cx">         var pc = new RTCPeerConnection();
</span><span class="cx">         pc.createDataChannel('sendDataChannel');
</span><span class="lines">@@ -21,25 +23,29 @@
</span><span class="cx">                 counter++;
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><del>-            assert_false(pc.localDescription.sdp.indexOf("a=candidate") === -1);
-            if (counter !== 0) {
-                // Redoing an offer now that we have some candidates.
</del><ins>+            assert_equals(pc.localDescription.sdp.indexOf("a=candidate"), -1);
+            if (counter === 0) {
</ins><span class="cx">                 pc.createOffer().then((offer) => {
</span><del>-                    assert_false(offer.sdp.indexOf("a=candidate") === -1);
</del><ins>+                    assert_equals(offer.sdp.indexOf("a=candidate"), -1);
</ins><span class="cx">                     resolve();
</span><span class="cx">                 });
</span><span class="cx">             } else
</span><del>-                reject("Host candidates should be found");
</del><ins>+                reject("No candidate should be found");
</ins><span class="cx">         };
</span><del>-        pc.createOffer().then((offer) => { pc.setLocalDescription(offer); });
</del><ins>+        pc.createOffer().then((offer) => {
+            assert_equals(offer.sdp.indexOf("a=candidate"), -1);
+            pc.setLocalDescription(offer);
+        });
</ins><span class="cx">     });
</span><del>-}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering off");
</del><ins>+}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering on");
</ins><span class="cx"> 
</span><span class="cx"> promise_test((test) => {
</span><del>-    if (window.internals)
-        internals.setICECandidateFiltering(true);
</del><ins>+    return new Promise((resolve, reject) => {
+        setTimeout(() => { reject("Test timed out"); }, 5000);
</ins><span class="cx"> 
</span><del>-    return new Promise((resolve, reject) => {
</del><ins>+        if (window.internals)
+            internals.setICECandidateFiltering(false);
+
</ins><span class="cx">         var counter = 0;
</span><span class="cx">         var pc = new RTCPeerConnection();
</span><span class="cx">         pc.createDataChannel('sendDataChannel');
</span><span class="lines">@@ -48,21 +54,19 @@
</span><span class="cx">                 counter++;
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><del>-            assert_equals(pc.localDescription.sdp.indexOf("a=candidate"), -1);
-            if (counter === 0) {
</del><ins>+            assert_false(pc.localDescription.sdp.indexOf("a=candidate") === -1);
+            if (counter !== 0) {
+                // Redoing an offer now that we have some candidates.
</ins><span class="cx">                 pc.createOffer().then((offer) => {
</span><del>-                    assert_equals(offer.sdp.indexOf("a=candidate"), -1);
</del><ins>+                    assert_false(offer.sdp.indexOf("a=candidate") === -1);
</ins><span class="cx">                     resolve();
</span><span class="cx">                 });
</span><span class="cx">             } else
</span><del>-                reject("No candidate should be found");
</del><ins>+                reject("Host candidates should be found");
</ins><span class="cx">         };
</span><del>-        pc.createOffer().then((offer) => {
-            assert_equals(offer.sdp.indexOf("a=candidate"), -1);
-            pc.setLocalDescription(offer);
-        });
</del><ins>+        pc.createOffer().then((offer) => { pc.setLocalDescription(offer); });
</ins><span class="cx">     });
</span><del>-}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering on");
</del><ins>+}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering off");
</ins><span class="cx">     </script>
</span><span class="cx">   </body>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcdatachanneltesthtmlfromrev218407trunkLayoutTestswebrtcdatachannelbasichtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/webrtc/datachannel/test.html (from rev 218407, trunk/LayoutTests/webrtc/datachannel/basic.html) (0 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/datachannel/test.html                           (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/test.html      2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -0,0 +1,133 @@
</span><ins>+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Testing basic data channel from offerer to receiver</title>
+    <script src="../../resources/testharness.js"></script>
+    <script src="../../resources/testharnessreport.js"></script>
+  </head>
+  <body>
+    <script src ="../routines.js"></script>
+    <script>
+var localChannel;
+var remoteChannel;
+
+function closeDataChannels() {
+    localChannel.close();
+    remoteChannel.close();
+    closeConnections();
+}
+
+function receiveMessages(event)
+{
+    try {
+        if (++counter === 1)
+            assert_equals(event.data, "one");
+        else if (counter === 2)
+            assert_equals(event.data, "two");
+        else if (counter === 3)
+            assert_equals(event.data, "three");
+        else if (counter === 4) {
+            assert_equals(event.data, "four");
+            closeDataChannels();
+            finishTest();
+        } else
+            assert_unreached();
+    } catch(e) {
+        console.log(e);
+    }
+}
+
+function sendMessages(channel)
+{
+    channel.send("one");
+    channel.send("two");
+    channel.send("three");
+    channel.send("four");
+}
+
+var finishTest;
+promise_test((test) => {
+    counter = 0;
+    return new Promise((resolve, reject) => {
+        finishTest = resolve;
+        createConnections((localConnection) => {
+            localChannel = localConnection.createDataChannel('sendDataChannel');
+            localChannel.onopen = () => { sendMessages(localChannel) };
+        }, (remoteConnection) => {
+            remoteConnection.ondatachannel = (event) => {
+                remoteChannel = event.channel;
+                remoteChannel.onmessage = receiveMessages;
+            };
+        });
+        setTimeout(() => { reject("Test timed out"); }, 5000);
+    });
+}, "Basic data channel exchange from offerer to receiver");
+
+promise_test((test) => {
+    counter = 0;
+    return new Promise((resolve, reject) => {
+        finishTest = resolve;
+        createConnections((localConnection) => {
+            localChannel = localConnection.createDataChannel('sendDataChannel');
+            localChannel.onmessage = receiveMessages;
+        }, (remoteConnection) => {
+            remoteConnection.ondatachannel = (event) => {
+                remoteChannel = event.channel;
+                remoteChannel.onopen = () => { sendMessages(remoteChannel) };
+            };
+        });
+        setTimeout(() => { reject("Test timed out"); }, 5000);
+    });
+}, "Basic data channel exchange from receiver to offerer");
+
+
+promise_test((test) => {
+    counter = 0;
+    return new Promise((resolve, reject) => {
+        finishTest = resolve;
+        createConnections((localConnection) => {
+            localChannel = localConnection.createDataChannel('sendDataChannel');
+            localChannel.onopen = () => { sendMessages(localChannel) };
+        }, (remoteConnection) => {
+            remoteConnection.ondatachannel = (event) => {
+                remoteChannel = event.channel;
+                remoteChannel.onmessage = receiveMessages;
+            };
+        }, { filterOutICECandidate: (candidate) => { return candidate && candidate.candidate.toLowerCase().indexOf("udp") == -1; } });
+        setTimeout(() => { reject("Test timed out"); }, 5000);
+    });
+}, "Basic data channel exchange from offerer to receiver using UDP only");
+
+promise_test((test) => {
+    counter = 0;
+    return new Promise((resolve, reject) => {
+        var checkDataChannelOptions = (channel, init) => {
+            assert_equals(channel.ordered, init.ordered, "ordered");
+            assert_equals(channel.maxPacketLifeTime, init.maxPacketLifeTime, "maxPacketLifeTime");
+            assert_equals(channel.maxRetransmitTime, init.maxRetransmitTime, "maxRetransmitTime");
+            assert_equals(channel.maxRetransmits, init.maxRetransmits, "maxRetransmits");
+            assert_equals(channel.protocol, init.protocol, "protocol");
+            assert_equals(channel.negotiated, init.negotiated, "negotiated");
+            assert_equals(channel.id, init.id, "id");
+        };
+
+        finishTest = resolve;
+        createConnections((localConnection) => {
+            var init = { ordered: true, maxPacketLifeTime: 10, maxRetransmitTime: 11, protocol: "whatever", negotiated: false, id: 1 };
+            localChannel = localConnection.createDataChannel('sendDataChannel', init);
+            checkDataChannelOptions(localChannel, init)
+            localChannel.onopen = () => { sendMessages(localChannel) };
+        }, (remoteConnection) => {
+            remoteConnection.ondatachannel = (event) => {
+                remoteChannel = event.channel;
+                remoteChannel.onmessage = receiveMessages;
+            };
+        });
+        setTimeout(() => { reject("Test timed out"); }, 5000);
+    });
+}, "Basic data channel exchange from offerer to receiver");
+
+    </script>
+  </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcvideostatshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/video-stats.html (218407 => 218408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-stats.html        2017-06-16 20:22:36 UTC (rev 218407)
+++ trunk/LayoutTests/webrtc/video-stats.html   2017-06-16 20:24:09 UTC (rev 218408)
</span><span class="lines">@@ -57,11 +57,20 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function testTimestampDifference(timeStampDifference, numberOfFrames)
+{
+    // Let's ensure timestamp is not in microseconds but milliseconds.
+    return timeStampDifference > 100000 * (numberOfFrames / 30.0);
+}
+
</ins><span class="cx"> function checkInboundFramesNumberIncreased(secondConnection, statsSecondConnection, count)
</span><span class="cx"> {
</span><span class="cx">     return getInboundRTPStats(secondConnection).then((stats) => {
</span><del>-        if (stats.timestamp > statsSecondConnection.timestamp && stats.framesDecoded > statsSecondConnection.framesDecoded)
</del><ins>+        if (stats.framesDecoded > statsSecondConnection.framesDecoded) {
+            if (testTimestampDifference(stats.timestamp - statsSecondConnection.timestamp, stats.framesDecoded - statsSecondConnection.framesDecoded))
+                return Promise.reject("timestamp and frames increment do not match");
</ins><span class="cx">             return;
</span><ins>+        }
</ins><span class="cx">         if (++count === 20)
</span><span class="cx">             return Promise.reject("checking inbound stats frame number increasing timed out");
</span><span class="cx">         return waitFor(50).then(() => {
</span><span class="lines">@@ -73,8 +82,11 @@
</span><span class="cx"> function checkOutboundFramesNumberIncreased(firstConnection, statsFirstConnection, count)
</span><span class="cx"> {
</span><span class="cx">     return getOutboundRTPStats(firstConnection).then((stats) => {
</span><del>-        if (stats.timestamp > statsFirstConnection.timestamp && stats.framesEncoded > statsFirstConnection.framesEncoded)
</del><ins>+        if (stats.framesEncoded > statsFirstConnection.framesEncoded) {
+            if (testTimestampDifference(stats.timestamp - statsFirstConnection.timestamp, stats.framesEncoded - statsFirstConnection.framesEncoded))
+                return Promise.reject("timestamp and frames increment do not match");
</ins><span class="cx">             return;
</span><ins>+        }
</ins><span class="cx">         if (++count === 20)
</span><span class="cx">             return Promise.reject("checking outbound stats frame number increasing timed out");
</span><span class="cx">         return waitFor(50).then(() => {
</span><span class="lines">@@ -110,7 +122,6 @@
</span><span class="cx">         assert_true(!!stats, "outbound-rtp stats should not be null");
</span><span class="cx">         assert_true(Number.isInteger(stats.framesEncoded), "framesEncoded should be an integer");
</span><span class="cx">         assert_true(Number.isInteger(stats.qpSum), "outbound qpSum should be an integer");
</span><del>-        assert_false(Number.isInteger(stats.timestamp), "timestamp should be a double");
</del><span class="cx">         assert_true(typeof stats.timestamp === "number", "timestamp should be a double");
</span><span class="cx">         statsFirstConnection = stats;
</span><span class="cx">         return getInboundRTPStats(secondConnection);
</span><span class="lines">@@ -118,7 +129,6 @@
</span><span class="cx">         assert_true(!!stats, "inbound-rtp stats should not be null");
</span><span class="cx">         assert_true(Number.isInteger(stats.framesDecoded), "framesDecoded should be an integer");
</span><span class="cx">         assert_true(Number.isInteger(stats.qpSum), "inbound qpSum should be an integer");
</span><del>-        assert_false(Number.isInteger(stats.timestamp), "timestamp should be a double");
</del><span class="cx">         assert_true(typeof stats.timestamp === "number", "timestamp should be a double");
</span><span class="cx">         statsSecondConnection = stats;
</span><span class="cx">     }).then(() => {
</span></span></pre>
</div>
</div>

</body>
</html>