Make some WebRTC tests easier to debug when failing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jun 2017 20:24:09 +0000 (20:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jun 2017 20:24:09 +0000 (20:24 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218408 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/webrtc/captureCanvas-webrtc-expected.txt
LayoutTests/webrtc/captureCanvas-webrtc.html
LayoutTests/webrtc/datachannel/basic-expected.txt
LayoutTests/webrtc/datachannel/basic-tcp-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/datachannel/basic-tcp.html [new file with mode: 0644]
LayoutTests/webrtc/datachannel/basic.html
LayoutTests/webrtc/datachannel/bufferedAmountLowThreshold.html
LayoutTests/webrtc/datachannel/creation-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/datachannel/creation.html [new file with mode: 0644]
LayoutTests/webrtc/datachannel/filter-ice-candidate-expected.txt
LayoutTests/webrtc/datachannel/filter-ice-candidate.html
LayoutTests/webrtc/datachannel/test.html [new file with mode: 0644]
LayoutTests/webrtc/video-stats.html

index e139678..3bc94f0 100644 (file)
@@ -1,3 +1,23 @@
+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.
+
 2017-06-16  Antoine Quint  <graouts@apple.com>
 
         REGRESSION: AirPlay placard is not shown when in fullscreen
index 9334707..36e7e58 100644 (file)
@@ -1,4 +1,7 @@
    
 
-PASS captureStream with webrtc 
+PASS Setting up the connection 
+PASS Checking canvas is green 
+PASS Checking canvas is red 
+PASS Checking canvas is green again 
 
index da29f7a..50ea4b9 100644 (file)
@@ -41,25 +41,32 @@ promise_test((test) => {
     }).then((stream) => {
         video.srcObject = stream;
         return video.play();
-    }).then(() => {
-         return waitFor(100);
-    }).then(() => {
+    });
+}, "Setting up the connection");
+
+promise_test((test) => {
+    return waitFor(100).then(() => {
         canvas2.getContext("2d").drawImage(video, 0 ,0);
         assert_array_equals(canvas2.getContext("2d").getImageData(20 ,20, 60, 60), canvas1.getContext("2d").getImageData(20, 20, 60, 60));
-    }).then(() => {
-        color = "red";
-         return waitFor(300);
-    }).then(() => {
+    });
+}, "Checking canvas is green");
+
+promise_test((test) => {
+    color = "red";
+    return waitFor(300).then(() => {
         canvas2.getContext("2d").drawImage(video, 0 ,0);
         assert_array_equals(canvas2.getContext("2d").getImageData(20 ,20, 60, 60), canvas1.getContext("2d").getImageData(20, 20, 60, 60));
-    }).then(() => {
-        color = "green";
-        return waitFor(300);
-    }).then(() => {
+    });
+}, "Checking canvas is red");
+
+
+promise_test((test) => {
+    color = "green";
+    return waitFor(300).then(() => {
         canvas2.getContext("2d").drawImage(video, 0 ,0);
         assert_array_equals(canvas2.getContext("2d").getImageData(20 ,20, 60, 60), canvas1.getContext("2d").getImageData(20, 20, 60, 60));
     });
-}, "captureStream with webrtc");
+}, "Checking canvas is green again");
         </script>
     </head>
 </html>
index ed5a4cd..0eb226e 100644 (file)
@@ -2,16 +2,5 @@
 PASS Basic data channel exchange from offerer to receiver 
 PASS Basic data channel exchange from receiver to offerer 
 PASS Basic data channel exchange from offerer to receiver using UDP only 
-PASS Basic data channel exchange from offerer to receiver using TCP only 
 PASS Basic data channel exchange from offerer to receiver 
-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 
 
diff --git a/LayoutTests/webrtc/datachannel/basic-tcp-expected.txt b/LayoutTests/webrtc/datachannel/basic-tcp-expected.txt
new file mode 100644 (file)
index 0000000..3ed518b
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Basic data channel exchange from offerer to receiver using TCP only 
+
diff --git a/LayoutTests/webrtc/datachannel/basic-tcp.html b/LayoutTests/webrtc/datachannel/basic-tcp.html
new file mode 100644 (file)
index 0000000..bf8fe7c
--- /dev/null
@@ -0,0 +1,71 @@
+<!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>
index 46d84e4..fa315d0 100644 (file)
@@ -19,6 +19,7 @@ function closeDataChannels() {
 }
 
 function receiveMessages(event) {
+try {
     if (++counter === 1)
         assert_equals(event.data, "one");
     else if (counter === 2)
@@ -31,6 +32,9 @@ function receiveMessages(event) {
         finishTest();
     } else
         assert_unreached();
+} catch(e) {
+    console.log(e);
+}
 }
 
 function sendMessages(channel)
@@ -55,6 +59,7 @@ promise_test((test) => {
                 remoteChannel.onmessage = receiveMessages;
             };
         });
+        setTimeout(() => { reject("Test timed out"); }, 5000);
     });
 }, "Basic data channel exchange from offerer to receiver");
 
@@ -71,9 +76,11 @@ promise_test((test) => {
                 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) => {
@@ -87,32 +94,13 @@ promise_test((test) => {
                 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) => {
-        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) => {
         var checkDataChannelOptions = (channel, init) => {
             assert_equals(channel.ordered, init.ordered, "ordered");
             assert_equals(channel.maxPacketLifeTime, init.maxPacketLifeTime, "maxPacketLifeTime");
@@ -134,72 +122,10 @@ promise_test((test) => {
                 remoteChannel.onmessage = receiveMessages;
             };
         });
+        setTimeout(() => { reject("Test timed out"); }, 5000);
     });
 }, "Basic data channel exchange from offerer to receiver");
 
-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>
index afc0c74..c145ab5 100644 (file)
@@ -9,6 +9,10 @@
   <body>
     <script src ="../routines.js"></script>
     <script>
+window.addEventListener("unhandledrejection", event => {
+    event.preventDefault();
+});
+
 var localChannel;
 var remoteChannel;
 
@@ -113,8 +117,6 @@ promise_test((test) => {
             };
         });
         setTimeout(resolve, 50);
-    }).then (() => {
-        closeDataChannels();
     });
 }, "Medium buffer threshold not reached");
     </script>
diff --git a/LayoutTests/webrtc/datachannel/creation-expected.txt b/LayoutTests/webrtc/datachannel/creation-expected.txt
new file mode 100644 (file)
index 0000000..b734f91
--- /dev/null
@@ -0,0 +1,12 @@
+
+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 
+
diff --git a/LayoutTests/webrtc/datachannel/creation.html b/LayoutTests/webrtc/datachannel/creation.html
new file mode 100644 (file)
index 0000000..06358b6
--- /dev/null
@@ -0,0 +1,76 @@
+<!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>
index 9adc81d..6f6f675 100644 (file)
@@ -1,4 +1,4 @@
 
-PASS Gathering ICE candidates from a data channel peer connection with ICE candidate filtering off 
 PASS Gathering ICE candidates from a data channel peer connection with ICE candidate filtering on 
+PASS Gathering ICE candidates from a data channel peer connection with ICE candidate filtering off 
 
index 5ea9b8e..8e7b033 100644 (file)
@@ -9,10 +9,12 @@
   <body>
     <script>
 promise_test((test) => {
-    if (window.internals)
-        internals.setICECandidateFiltering(false);
-
     return new Promise((resolve, reject) => {
+        setTimeout(() => { reject("Test timed out"); }, 5000);
+
+        if (window.internals)
+            internals.setICECandidateFiltering(true);
+
         var counter = 0;
         var pc = new RTCPeerConnection();
         pc.createDataChannel('sendDataChannel');
@@ -21,25 +23,29 @@ promise_test((test) => {
                 counter++;
                 return;
             }
-            assert_false(pc.localDescription.sdp.indexOf("a=candidate") === -1);
-            if (counter !== 0) {
-                // Redoing an offer now that we have some candidates.
+            assert_equals(pc.localDescription.sdp.indexOf("a=candidate"), -1);
+            if (counter === 0) {
                 pc.createOffer().then((offer) => {
-                    assert_false(offer.sdp.indexOf("a=candidate") === -1);
+                    assert_equals(offer.sdp.indexOf("a=candidate"), -1);
                     resolve();
                 });
             } else
-                reject("Host candidates should be found");
+                reject("No candidate should be found");
         };
-        pc.createOffer().then((offer) => { pc.setLocalDescription(offer); });
+        pc.createOffer().then((offer) => {
+            assert_equals(offer.sdp.indexOf("a=candidate"), -1);
+            pc.setLocalDescription(offer);
+        });
     });
-}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering off");
+}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering on");
 
 promise_test((test) => {
-    if (window.internals)
-        internals.setICECandidateFiltering(true);
-
     return new Promise((resolve, reject) => {
+        setTimeout(() => { reject("Test timed out"); }, 5000);
+
+       if (window.internals)
+            internals.setICECandidateFiltering(false);
+
         var counter = 0;
         var pc = new RTCPeerConnection();
         pc.createDataChannel('sendDataChannel');
@@ -48,21 +54,19 @@ promise_test((test) => {
                 counter++;
                 return;
             }
-            assert_equals(pc.localDescription.sdp.indexOf("a=candidate"), -1);
-            if (counter === 0) {
+            assert_false(pc.localDescription.sdp.indexOf("a=candidate") === -1);
+            if (counter !== 0) {
+                // Redoing an offer now that we have some candidates.
                 pc.createOffer().then((offer) => {
-                    assert_equals(offer.sdp.indexOf("a=candidate"), -1);
+                    assert_false(offer.sdp.indexOf("a=candidate") === -1);
                     resolve();
                 });
             } else
-                reject("No candidate should be found");
+                reject("Host candidates should be found");
         };
-        pc.createOffer().then((offer) => {
-            assert_equals(offer.sdp.indexOf("a=candidate"), -1);
-            pc.setLocalDescription(offer);
-        });
+        pc.createOffer().then((offer) => { pc.setLocalDescription(offer); });
     });
-}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering on");
+}, "Gathering ICE candidates from a data channel peer connection with ICE candidate filtering off");
     </script>
   </body>
 </html>
diff --git a/LayoutTests/webrtc/datachannel/test.html b/LayoutTests/webrtc/datachannel/test.html
new file mode 100644 (file)
index 0000000..e2ab31b
--- /dev/null
@@ -0,0 +1,133 @@
+<!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>
index 3340bf1..bfc10f0 100644 (file)
@@ -57,11 +57,20 @@ function getOutboundRTPStats(connection)
     });
 }
 
+function testTimestampDifference(timeStampDifference, numberOfFrames)
+{
+    // Let's ensure timestamp is not in microseconds but milliseconds.
+    return timeStampDifference > 100000 * (numberOfFrames / 30.0);
+}
+
 function checkInboundFramesNumberIncreased(secondConnection, statsSecondConnection, count)
 {
     return getInboundRTPStats(secondConnection).then((stats) => {
-        if (stats.timestamp > statsSecondConnection.timestamp && stats.framesDecoded > statsSecondConnection.framesDecoded)
+        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");
             return;
+        }
         if (++count === 20)
             return Promise.reject("checking inbound stats frame number increasing timed out");
         return waitFor(50).then(() => {
@@ -73,8 +82,11 @@ function checkInboundFramesNumberIncreased(secondConnection, statsSecondConnecti
 function checkOutboundFramesNumberIncreased(firstConnection, statsFirstConnection, count)
 {
     return getOutboundRTPStats(firstConnection).then((stats) => {
-        if (stats.timestamp > statsFirstConnection.timestamp && stats.framesEncoded > statsFirstConnection.framesEncoded)
+        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");
             return;
+        }
         if (++count === 20)
             return Promise.reject("checking outbound stats frame number increasing timed out");
         return waitFor(50).then(() => {
@@ -110,7 +122,6 @@ promise_test((test) => {
         assert_true(!!stats, "outbound-rtp stats should not be null");
         assert_true(Number.isInteger(stats.framesEncoded), "framesEncoded should be an integer");
         assert_true(Number.isInteger(stats.qpSum), "outbound qpSum should be an integer");
-        assert_false(Number.isInteger(stats.timestamp), "timestamp should be a double");
         assert_true(typeof stats.timestamp === "number", "timestamp should be a double");
         statsFirstConnection = stats;
         return getInboundRTPStats(secondConnection);
@@ -118,7 +129,6 @@ promise_test((test) => {
         assert_true(!!stats, "inbound-rtp stats should not be null");
         assert_true(Number.isInteger(stats.framesDecoded), "framesDecoded should be an integer");
         assert_true(Number.isInteger(stats.qpSum), "inbound qpSum should be an integer");
-        assert_false(Number.isInteger(stats.timestamp), "timestamp should be a double");
         assert_true(typeof stats.timestamp === "number", "timestamp should be a double");
         statsSecondConnection = stats;
     }).then(() => {